No module named warnings when starting GAE inside virtualenv locally
I am trying to run my GAE app locally inside a virtual environment.
I’ve followed these two articles [1], [2] as reference to setup, but when I source evn/bin/activate and then dev_appserver.py . , it keeps raising the error of ImportError: No module named warnings (more trace below)
Surprisingly, if I start it without activating virtual env by just running dev_appserver.py . inside root of project it runs without any issue.
Is there any solution or workaround for this problem?
INFO 2017-08-31 14:09:36,293 devappserver2.py:116] Skipping SDK update check. INFO 2017-08-31 14:09:36,354 api_server.py:313] Starting API server at: http://localhost:52608 INFO 2017-08-31 14:09:36,357 dispatcher.py:226] Starting module "default" running at: http://localhost:8080 INFO 2017-08-31 14:09:36,359 admin_server.py:116] Starting admin server at: http://localhost:8000 Traceback (most recent call last): File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/_python_runtime.py", line 103, in _run_file(__file__, globals()) File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/_python_runtime.py", line 97, in _run_file execfile(_PATHS.script_file(script_name), globals_) File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime.py", line 192, in main() File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime.py", line 172, in main sandbox.enable_sandbox(config) File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 326, in enable_sandbox __import__('%s.threading' % dist27.__name__) File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/dist27/threading.py", line 11, in import warnings File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 1076, in load_module raise ImportError('No module named %s' % fullname) ImportError: No module named warnings ERROR 2017-08-31 14:09:39,070 instance.py:280] Cannot connect to the instance on localhost:52366
Что означает ошибка ModuleNotFoundError: No module named
Ситуация: мы решили заняться бигдатой и обработать большой массив данных на Python. Чтобы было проще, мы используем уже готовые решения и находим нужный нам код в интернете, например такой:
import numpy as np x = [2, 3, 4, 5, 6] nums = np.array([2, 3, 4, 5, 6]) type(nums) zeros = np.zeros((5, 4)) lin = np.linspace(1, 10, 20)
Копируем, вставляем в редактор кода и запускаем, чтобы разобраться, как что работает. Но вместо обработки данных Python выдаёт ошибку:
❌ModuleNotFoundError: No module named numpy
Странно, но этот код точно правильный: мы его взяли из блога разработчика и, по комментариям, у всех всё работает. Откуда тогда ошибка?
Что это значит: Python пытается подключить библиотеку, которую мы указали, но не может её найти у себя.
Когда встречается: когда библиотеки нет или мы неправильно написали её название.
Что делать с ошибкой ModuleNotFoundError: No module named
Самый простой способ исправить эту ошибку — установить библиотеку, которую мы хотим подключить в проект. Для установки Python-библиотек используют штатную команду pip или pip3, которая работает так: pip install . В нашем случае Python говорит, что он не может подключить библиотеку Numpy, поэтому пишем в командной строке такое:
Это нужно написать не в командной строке Python, а в командной строке операционной системы. Тогда компьютер скачает эту библиотеку, установит, привяжет к Python и будет ругаться на строчку в коде import numpy.
Ещё бывает такое, что библиотека называется иначе, чем указано в команде pip install. Например, для работы с телеграм-ботами нужна библиотека telebot, а для её установки надо написать pip install pytelegrambotapi . Если попробовать подключить библиотеку с этим же названием, то тоже получим ошибку:
А иногда такая ошибка — это просто невнимательность: пропущенная буква в названии библиотеки или опечатка. Исправляем и работаем дальше.
В «Яндекс Практикуме» можно стать разработчиком, тестировщиком, аналитиком и менеджером цифровых продуктов. Первая часть обучения всегда бесплатная, чтобы попробовать и найти то, что вам по душе. Дальше — программы трудоустройства.
Python for .NET: ImportError: No module named warnings
@SilentGhost I don’t know if you figured this out, but you need to set your PYTHONPATH environment variable rather than your PYTHONHOME variable. I, too, had the problem, set the environment variable with the ol’ Environment.SetVariable(«PYTHONPATH», . ) and everything worked out well in the end.
Good luck with the Python.NET.
I’m working with the 2.4 version of Python.NET with Python 3.6 and I had similar issues. I didn’t have much luck setting environment variables at runtime but I found the following approach worked.
I found Python.NET was picking up all packages in the folders defined in the static PythonEngine.PythonPath variable. If you have other directories set in the PYTHONPATH system variable, it will also include these too.
To include module directories at runtime you can do something like
PythonEngine.PythonPath = PythonEngine.PythonPath + ";" + moduleDirectory; using (Py.GIL())
Make sure you set the PythonEngine.PythonPath variable before making any calls to the python engine.
Also needed to restart visual studio to see any system variable changes take effect when debugging.
As a side note, I also found that my \Python36\Lib\site-packages folder path needed to be added to PYTHONPATH to pick up anything installed through pip.
I think by default the Python Engine does not set the paths you need automatically.
http://www.voidspace.org.uk/ironpython/custom_executable.shtml has an example for embedding ironpython. Looks like you are missing something like
PythonEngine engine = new PythonEngine(); engine.AddToPath(Path.GetDirectoryName(Application.ExecutablePath)); engine.AddToPath(MyPathToStdLib);
Unless I know where and if Ironpython is installed, I prefer to find all of the standard modules I need, compile them to a IPyStdLibDLL and then do th following from my code
import clr clr.addReference("IPyStdLib") import site
Related Query
- ImportError: No module named libvirt error whyle trying to install python for libvirt on NetBSD 9.2
- python module for CGH analysis
- What python web interaction module should be used for https?
- Regular expression for getting viewstate from page using python re module
- Named entity recognition with preset list of names for Python / PHP
- python ImportError: No module named primes
- python iterate nested classes for module
- ModuleNotFoundError: No module named ‘_dbus_bindings’ debian 11 bullseye python 3.9.2
- Add custom log level for pytest tests to python the logging module
- Is there a python module that provides a test for equivalent Unicode characters?
- some module has no attribute ‘something’ for tkinter to work with two python files
- No module named pip which using virtualenv-based python
- Should one avoid a Python module being named in its own namespace?
- I’m getting Import Error: No Module Named ecommerce.shipping in Python
- ImportError: No module named unable to import toplevel directory of module in python
- Module Not Found Error for ‘pdf2image’ in Python Script
- How to install ctypes module for python 3.7 to be used with VSCode debugger
- Can’t run python script from command line NO MODULE NAMED project_name
- How to change the linker command for building a C++ extension module in Python setup.py?
- Azure Function ImportError while importing test module / ModuleNotFoundError: No module named
- VS Code Python import module doesnt work ModuleNotFoundError: No module named ‘words’
- What is the hierarchy for Python module imports?
- ModuleNotFoundError: No module named ‘factor_analyzer’ — Python Notebook
- ImportError No Module Named ‘PyPDF2’
- python module not found error no module named
- Unable to install the googleads module for python in anaconda (Spyder)
- Python Module for Non-canonical Keyboard Input Processing
- Python — numpy: No module named ‘_ctypes’
- Python no module named ‘requests’ even install requests
- No module named ‘cv2’ during importing in python
- Invalid URI for url using ? in python requests module
- python ModuleNotFoundError: No module named ‘gplearn’
- How to solve «ImportError: No module named dis3» when making stand-alone executable file from python script
- Python — ImportError: No module named ‘pymongo’ despite pip says «requirement already satisfied» [Windows]
- What’s required for Python Click script to access it’s own module directory?
- Is there a python module for ip locator
- No module named ‘redis’ with python code
- apache-storm mixed topology with python — ModuleNotFoundError: No module named ‘storm’
- «No module named yum» with Python 2.7
- PDF to text Python 3.6 pdfminer no module named ‘pdfminer’
- Importing library once for a python module
- python v 2.7.13 with twilio v 6.5.2 cannot find module named urllib3 when importing Client
- ModuleNotFoundError: No module named ‘Tkinter’ in python using python 3
- Built-in module for bayesian curve fitting in python
- ImportError: No module named requests using two versions of python
- No module named matplotlib with matplotlib installed Python 2.7
- Using findall function in module re for python
- Python package No module ImportError
- Python best practice for importing grandparent module in parent and child modules
- Heapsort not working in Python for list of strings using heapq module
More Query from same tag
- Python gzip and Java GZIPOutputStream give different results
- Send a Facebook Message with XMPP using Access Tokens in Python
- train_test_split exception with 2D labels as stratify array
- Reading and writing to a csv using iteration
- Attempting to update 500+ vertex positions in OpenGL causes a read access violation?
- Why my «networkx» plot is inaccurate and does not visualize my input data?
- gcp — python sdk — get firewall
- Update URLs used by conda for Linux 64 packages
- Understanding Seaborn Boxplot With Examples
- how to group by and sample unique rows that are not repeated in other groups
- BeautifulSoup or regex HTML table to data structure?
- How can I save filled missing data after using XGBClassifier?
- How Do You Select VALUES using Xpath’s starts-with?
- Avoiding global variables in Python as a new programmer
- Integrate Pylint with PyCharm
- Replace With Next Largest Number
- Python on Gitlab has ModuleNotFound, But Not When I Run Locally
- Errors with Atari Environments in PettingZooML
- function to check if a number is prime not giving output
- How can I loop over the @pytest.mark.parametrize data or print it on the tests
- Splitting a string in sub-strings python
- only convert to date cells with data
- name ‘x’ is not defined
- Is there anyone who’s able to figure out how to print the table in the picture I provided?
- Converting Maple to Sage
- Parse multiple line CSV using PySpark , Python or Shell
- Can’t use function in data frame which is converted from Html File
- How to make 2 functions for 2 tkinter windows more condensed?
- Full factorization of polynomials over complexes with SymPy
- conda install conda finds conflicts on fresh install
- What makes python stall when running http.server
- Instance variable name a reserved word in Python
- Enumerate devices connected to my router using python 3 in Windows
- thread synchronization using message queues is not in order
- Create Dummy variables from multiple variables in python