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
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.
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 execute a python script on boot. The script runs fine in a shell, but when I boot I got an import error for zmq package, here's the cronlog:
Traceback (most recent call last):
File "/home/elachere/Documents/mg_app/r_server.py", line 7, in <module>
import zmq
ImportError: No module named zmq
I saw many posts about this, so far I tried :
-exports PYTHONPATH in my bash_profile and run the python script via a bash script
-add these lines to my python script (before zmq import):
#!/usr/bin/python
import sys
sys.path.append('/home/elachere/.local/lib/python2.7/site-packages/zmq/')
-set PYTHONPATH at the top of my crontab
Unfortunately nothing worked, I still get the import error.
Thanks in advance for your response.
I've installed and configurated AWS Elastic Beanstalk Command Line Tool on my Mac.
That's what I have installed:
$ python --version
Python 2.7
$ ruby --version
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin10.8.0]
$ eb --version
AWS Elastic Beanstalk Command Line Interface v2.6.3
I have EB properly configured in order to use git with AWS
When I try to push a commit to AWS I am getting this error:
$ git aws.push
Traceback (most recent call last):
File ".git/AWSDevTools/aws.elasticbeanstalk.push", line 21, in <module>
from aws.dev_tools import *
File "/Applications/MAMP/htdocs/innbativel/.git/AWSDevTools/aws/dev_tools.py", line 3, in <module>
from subprocess import check_output
ImportError: cannot import name check_output
Does anyone have an idea why and how to fix it?
I found that my OSX comes with python 2.6 (which doesn't have check_output) and it was conflicting with python 2.7 that I've installed for EB CLI.
To solve this, I just made .git/AWSDevTools/aws.elasticbeanstalk.push use python 2.7, in its first line:
#!/usr/bin/env python2.7