python virtualenv ImportError with celery and bill

2019-06-02 21:52发布

问题:

i am building a new amazon instance with python 2.7.10 as default. after i have ran my machine provisioning scripts and the moment of truth arrives, celery gave me an import so i debugged the problem to billard.

the package appears to be in the correct path i.e.

sudo find -name "billiard"
./srv/ia-live/lib64/python2.7/dist-packages/billiard

where ia-live is the path of my virtualenv. checking the path in via python virtualenv executable

import sys
sys.path

['',
 '/srv/ia-live/bin',
 '/srv/ia-live/src/django-devserver-redux-master',
 '/usr/lib/python2.7',
 '/srv/ia-live/local/lib64/python2.7/site-packages',
 '/srv/ia-live/local/lib/python2.7/site-packages',
 '/srv/ia-live/lib64/python2.7',
 '/srv/ia-live/lib/python2.7',
 '/srv/ia-live/lib64/python2.7/site-packages',
 '/srv/ia-live/lib/python2.7/site-packages',
 '/srv/ia-live/lib64/python2.7/lib-dynload',
 '/srv/ia-live/local/lib/python2.7/dist-packages',
 '/srv/ia-live/local/lib/python2.7/dist-packages',
 '/srv/ia-live/lib/python2.7/dist-packages',
 '/usr/lib64/python2.7',
 '/usr/lib/python2.7',
 '/srv/ia-live/local/lib/python2.7/dist-packages/IPython/extensions',
 '/home/ec2-user/.ipython']

which appears to be correct, but when i do

import billiard
ImportError: No module named billiard

i don't understand why there could be problem

回答1:

i was able to identify the problem. It is with the default python27 virtualenv and devel packages that comes with ec2-ami

for me, i had to update the system pip and system virutalenv

using

sudo -i
pip install --upgrade pip
pip install --upgrade virtualenv

and the i hard ran /usr/bin/virtualenv to create a new virtualenv. it solved the problem for me.

hope it helps somebody else too.