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.
Related
I have created the docker image to run python script. Now when I run below command it throwing error.
command in powershell:
docker build -t pull_request_summary .
Error:
Traceback (most recent call last):
File "/usr/app/src/./listPullRequest.py", line 1, in
import requests
ModuleNotFoundError: No module named 'requests'
Just to confirm the "requests module is already installed on my machine. The script is running fine if I directly run from PowerShell. It just throwing error while running docker images.
My question is where it is expecting the "request" module of python?
your container also must have requests installed on it
In your docker file put this line
RUN pip install requests
I had this same error even when including RUN pip install requests in the Dockerfile. My solution was to change from:
CMD ./myscript.py
to:
CMD [ "python", "./myscript.py" ]
I'm not able to run a Python script from ExecuteStreamCommand.
These are the processor properties:
Command arguments: /home/directory/test.py
Command path: /bin/python3
Working directory: /home/directory
Error message: Traceback (most recent call last): File "/home/test.py", line 1, in import nipyapi ModuleNotFoundError: No module named 'nipyapi'
The way that I am able to get ExecuteStreamCommand processor to run python scripts with imported modules is to install the imported modules on the actual machine itself. Therefore, this means running pip or pip3 install {insert module name} on the command prompt for each system that this processor is running on.
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.
I have a simple python script
import boto3
print('I know you are installed')
I'm sure the boto3 module is installed
pip3 install boto3
If run via terminal
python3 test.py
I get the expected output
I know you are installed
If I run the same script via Upstart
description "test"
author "me"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
chdir /var/www/html/
script
exec nohup /usr/bin/python3 -u /var/www/html/test.py >
/var/www/html/test.log
end script
I get
tail: /var/www/html/test.log: file truncated
Traceback (most recent call last):
File "/var/www/html/test.py", line 1, in <module>
import boto3
ImportError: No module named 'boto3'
Why can't the boto3 module be found when running the script from Upstart?
I ended having to add the following to my script
sys.path.append("/home/ubuntu/.local/lib/python3.5/site-packages")
Seems as though when running python via Upstart, even though it was using 3.5 it wasn't looking in that site-packages directory
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