I have added celery in my miniconda distribution. But when I try to run it I get the following error
Traceback (most recent call last):
File "C:\Miniconda2\Scripts\celery-script.py", line 6, in <module>
sys.exit(main())
File "C:\Miniconda2\lib\site-packages\celery\__main__.py", line 29, in main
from celery.bin.celery import main
ImportError: No module named celery
entering the python env through miniconda (C:\Miniconda2 python.exe) and importing celery works
>>import celery
>>
I have also Python 2.7 installed which does not have celery. Do you think its that?
You've answered your own question. In the first code block you're most likely running your python in C:\Python27. In the second code block you're actually running the python with celery in it.
You should read up on managing and activating conda environments. http://conda.pydata.org/docs/using/envs.html
Related
When I start a new Django Project it works perfectly but after I shutdown or restart my PC it does not work. Even though I have activated my virtual environment it keeps giving me errors.
This what the error says:
Traceback (most recent call last):
File "C:\Users\SUCCESS-AKINYEMI\Desktop\studybud\manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\SUCCESS-AKINYEMI\Desktop\studybud\manage.py", line 22, in main()
File "C:\Users\SUCCESS-AKINYEMI\Desktop\studybud\manage.py", line 13, 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?
I tried it on another laptop and it worked, but it is not working on my own laptop.
make sure that python is added to the path
in windows try
windows logo + pause -> Advanced system settings -> Environment variables
if python it's not on the list add it.
for Value insert something like this
C:\Users\username\AppData\Local\Programs\Python\Python310\Scripts\
also make sure that you use the keyword py in your commands
for example :
py manage.py runserver
When I first ran the server everything was fine and the project was running properly. But after few days when I ran the server again, it gave me an error
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Django Project\first\manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Django Project\first\manage.py", line 22, in <module>
main()
File "C:\Users\Admin\Desktop\Django Project\first\manage.py", line 13, 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?
To be specific, I'm on Windows 10, using VS Code as my IDE (I've not setup any virtual environment).
Django version installed - 3.2.9
Python version installed - 3.10.0
PIP version installed - 21.2.3
Here is a screenshot of my Environment Variables
[
I don't know what the problem was. Thanks to everyone for their suggestions. I deleted the project and created a new one and it worked. I hope I won't face any such issue while working on a big project!
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.
Working on the celery upstarting for my flask project. When using the upstart command(sudo /etc/init.d/celeryd start) I get
celery init v10.1.
Using config script: /etc/default/celeryd
Traceback (most recent call last):
File "/home/user/.local/bin/celery", line 7, in <module>
from celery.__main__ import main
ModuleNotFoundError: No module named 'celery'
My bin file for celery is placed in /home/user/.local/bin/celery. Directly running celery -A project worker -l info in terminal is working fine.
You can install the module celery via pip.
Make sure pip is accessible through the command prompt - if not set it with an environment variable.
Once it's okay then simply type the command
pip install celery
and the module will be installed.
I'm trying to run a Python script (testing.py) as a cron job. I have CentOS with a separate python2.7 interpreter path, so I've added the following shebang:
#!/usr/local/bin/python2.7
However, when the cron job runs I get the following error
Traceback (most recent call last):
File "/root/carsales/carsales_v2.py", line 3, in <module>
import pandas as pd
ImportError: No module named pandas
I have installed Anaconda, and if I run the python2.7 interpreter through the command line, as:
python2.7 testing.py
It imports pandas successfully. However, running it directly (as per below) fails to import:
./testing.py
So there's some problem with the shebang, or possibly with the Anaconda install?