I use codeanywhere.com try to create application with Python werkzeug and jinja2.
I install those library utilize virtualenv. Now I face the problem
Traceback (most recent call last):
File "manage.py", line 4, in
from werkzeug import Request
ImportError: No module named 'werkzeug'
virtualenv activated but nothing is works.
Does anybody has experience with codeanywhere.com?
Oh I solve this problem. In the container config file add instruction "source venv3/bin/activate" as shown on a picture add path to python as well.
enter image description here
Related
So I was trying to install django. I have used pip3 install django, and this what happened:
Then i tried to look if my django was having no problem by typing import django on python. But this what happened to me:
Can anyone help me? Thanks, it helps me a lot!
You installed Django for python 3. When you type python in the terminal you opening python 2.7(you can see that in terminal), so try python3 instead.
I'm new to using Django & Python and am having some difficulty trying to get my manage.py application to run in a virtual environment.
I am receiving the following errors at the top of my models.py file:
I initially thought that this was an issue with pylint not pointing at the right environment (when I switch my Python interpretter to the one outside of the virtual environment, the pylint errors disappear); however, whenever I try to run my server, I get the following error:
(.venv) tjmcerlean#LAPTOP-RKLCBQLO:/mnt/c/Users/tjmce/Desktop/Git/CS50w/Project 2/commerce$ python manage.py runserverTraceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/mnt/c/Users/tjmce/Desktop/Git/CS50w/Project 2/commerce/.venv/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
ModuleNotFoundError: No module named 'django.utils'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 12, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
This error appears to suggest that the virtual environment is not activated. However, I activated it using the location of the virtual environment (.venv/bin/activate) and saw that the bash terminal now displays (.venv):
Additionally, when using the (pip freeze) command, I can see that Django is installed within the virtual environment too:
I'm lost as to why the server won't run and would really appreciate any advice.
Thank you!
Calling django.__file__ in activated env reveals the real path:
python -c "import django; print(django.__file__)"
it should looks like /usr/local/lib/python3.8/site-packages/django/__init__.py
then re-check PYTHONPATH environment variable.
Maybe you've installed 2 Django in venv and system-wide but in some of them there is no db. And also remove all of *.pyc files in your working folder.
The problems occur when you don't include a path in virtualenv.
Try adding the path of python on your vscode.
Or, try to install and uninstall the Django projects.
When i try to run ovirt downloads_disk_snapshot from this link i am getting error as
Traceback (most recent call last):
File "download_disk_snapshots.py", line 22, in <module>
import ovirtsdk4 as sdk
ImportError: No module named ovirtsdk4
Link is https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/download_disk_snapshots.py
This guide gives some very useful information on installing python packages.
In your case, you will have to install the oVirt Engine SDK itself before being able to run the example.
Installation instructions are given within the same Github project that you are mentioning:
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/README.adoc#installation
I'm trying to use VirtualEnv for a Flask app that I'm creating since everyone has recommended me to do so. After creating my virtual environment, I installed the libraries that I needed using pip while the environment was activated. I'm running into ImportError problems with this script. The code works fine when I'm not in the virtual environment.
My script:
#!/usr/bin/python
import sc2reader
...
...
When I try to run it I get this:
(flaskapp)xxxx#xxxx-VirtualBox:~/flaskapp/bin$ ./test.py
Traceback (most recent call last):
File "./test.py", line 3, in <module>
import sc2reader
ImportError: No module named sc2reader
I've tried changing the shebang to reflect my VirtualEnv path for Python, but that didn't fix anything. The library is found in my site-packages folder in my virtual environment, so I'm not sure why I'm getting the ImportError.
I've never used VirtualEnv before so I'm assuming I configured it wrong so it's not seeing my site-packages.
Try using
#!/usr/bin/env python
as the shebang.
If that does not work, try seeing what is the output of which python.
I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9:
$ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/
$ python tut09_files.py
Traceback (most recent call last):
File "tut09_files.py", line 48, in <module>
from cherrypy.lib import static
ImportError: cannot import name static
The previous line in the file:
import cherrypy
passes without error, so it appears that it can find cherrypy on the path. What am I missing?
This works for me, and I'm also using CherryPy 3.1.0, so I'm not sure what to tell you.
Look in your /Library/Python/2.5/site-packages/cherrypy/lib directory for a file named static.py; if this file exists then I'm not sure what to tell you. If it doesn't then something has happened to your CherryPy and I'd advise you to reinstall. If it does then you should check the value of sys.path to make sure it's detecting the right version of CherryPy.
You can also try running the python interpreter on the command line and then doing a from cherrypy.lib import static to see if you get the same result.
I had an old CherryPy-2.3.0-py2.5.egg file in my site-packages. After removing the old .egg I could run the tutorial.