我在debian lenny下运行的服务器上部署了一个django项目。每次启动时都会弹出以下警告:
/var/www/environment/XXX/src/django-pytest/django_pytest/test_runner.py:3: UserWarning: Module _mysql was already imported from /usr/lib/pymodules/python2.6/_mysql.so, but /usr/lib/pymodules/python2.6 is being added to sys.path
from pkg_resources import load_entry_point
在该特定服务器上有多个Django项目,每个项目都在自己的virtualenv中运行(通过pip安装Python包)。但是,他们还可以访问系统范围的站点包(通过apt-get install
安装)。
此特定项目具有以下Python包:
$ /var/www/environment/XXX/bin/pip freeze --local
Django==1.2.4
Fabric==0.9.4
South==0.7.3
distribute==0.6.10
django-pagination==1.0.7
-e git+http://github.com/galileo-press/django-pytest.git@7c1fa0180ca16c129850de3c3d912cd369fba687#egg=django_pytest-0.1.4-py2.6-dev
django-sorting==0.1
django-templatetag-sugar==0.1
paramiko==1.7.6
py==1.4.3
pycrypto==2.3
pytest==2.0.0
在debian python-mysqldb 1.2.2-10 + b1已安装并且文件存在
$ apt-file list python-mysqldb
python-mysqldb: /usr/lib/pyshared/python2.5/_mysql.so
python-mysqldb: /usr/lib/pyshared/python2.6/_mysql.so
python-mysqldb: /usr/share/pyshared/MySQL_python-1.2.2.egg-info/PKG-INFO
python-mysqldb: /usr/share/pyshared/MySQL_python-1.2.2.egg-info/SOURCES.txt
python-mysqldb: /usr/share/pyshared/MySQL_python-1.2.2.egg-info/dependency_links.txt
python-mysqldb: /usr/share/pyshared/MySQL_python-1.2.2.egg-info/top_level.txt
python-mysqldb: /usr/share/pyshared/MySQLdb/__init__.py
...
虽然这只是一个小麻烦,但我真的很想解决这个问题。
有人可以帮忙吗?
更新:以下是yolk的输出:
Cheetah - 2.4.2.1 - active development (/usr/lib/pymodules/python2.6)
Django - 1.2.3 - non-active development (/usr/lib/pymodules/python2.6)
Django - 1.2.4 - active
Fabric - 0.9.4 - active
Jinja2 - 2.5.5 - active development (/usr/lib/pymodules/python2.6)
Logbook - 0.3 - active development (/usr/local/lib/python2.6/dist-packages/Logbook-0.3-py2.6-linux-x86_64.egg)
MarkupSafe - 0.9.2 - active development (/usr/lib/python2.6/dist-packages)
MySQL-python - 1.2.2 - active development (/usr/lib/pymodules/python2.6)
PIL - 1.1.7 - active development (/usr/lib/python2.6/dist-packages/PIL)
Python - 2.6.6 - active development (/usr/lib/python2.6/lib-dynload)
South - 0.7.3 - active
boto - 1.9b - active development (/usr/lib/pymodules/python2.6)
distribute - 0.6.10 - active
distribute - 0.6.14 - non-active development (/usr/lib/python2.6/dist-packages)
django-pagination - 1.0.7 - active
django-pytest - 0.1.4 - active development (/var/www/environment/XXX/src/django-pytest)
django-sorting - 0.1 - active
django-templatetag-sugar - 0.1 - active
flup - 1.0.2 - active development (/usr/lib/pymodules/python2.6)
lxml - 2.2.8 - active development (/usr/lib/python2.6/dist-packages)
mercurial - 1.6.4 - active development (/usr/lib/pymodules/python2.6)
paramiko - 1.7.6 - active
pip - 0.7.2 - active
psycopg2 - 2.2.1 - active development (/usr/lib/python2.6/dist-packages)
py - 1.3.3 - non-active development (/usr/lib/pymodules/python2.6)
py - 1.4.1 - non-active
py - 1.4.3 - active
pycrypto - 2.3 - active
pytest - 2.0.0 - active
python-amazon-product-api - 0.2.5a1 - active development (/var/www/environment/XXX/src/amazonproduct)
python-amazon-product-api - 0.2.5a1 - active development (/var/www/environment/XXX/src/amazonproduct)
python-amazon-product-api - 0.2.5a1 - non-active development (/usr/local/lib/python2.6/dist-packages/python_amazon_product_api-0.2.5a1-py2.6.egg)
python-amazon-product-api - 0.2.5a1 - non-active development (/usr/local/lib/python2.6/dist-packages/python_amazon_product_api-0.2.5a1-py2.6.egg)
python-dateutil - 1.4.1 - active development (/usr/lib/pymodules/python2.6)
setuptools - 0.6c11 - active development (/usr/lib/python2.6/dist-packages)
stdeb - 0.6.0 - active development (/usr/lib/pymodules/python2.6)
virtualenv - 1.4.9 - active development (/usr/lib/pymodules/python2.6)
web.py - 0.34 - active development (/usr/lib/pymodules/python2.6)
wsgiref - 0.1.2 - active development (/usr/lib/python2.6)
yolk - 0.4.1 - active
更新2:我的sys.path
是:
/var/www/environment/XXX/bin/python -c "import sys; print '\n'.join(sys.path)"
/var/www/environment/XXX/lib/python2.6/site-packages/distribute-0.6.10-py2.6.egg
/var/www/environment/XXX/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg
/var/www/environment/XXX/src/django-pytest
/var/www/environment/XXX/src/amazonproduct
/var/www/environment/XXX/lib/python2.6
/var/www/environment/XXX/lib/python2.6/plat-linux2
/var/www/environment/XXX/lib/python2.6/lib-tk
/var/www/environment/XXX/lib/python2.6/lib-old
/var/www/environment/XXX/lib/python2.6/lib-dynload
/usr/lib/python2.6
/usr/lib64/python2.6
/usr/lib/python2.6/plat-linux2
/usr/lib/python2.6/lib-tk
/usr/lib64/python2.6/lib-tk
/var/www/environment/XXX/lib/python2.6/site-packages
/usr/local/lib/python2.6/dist-packages/Logbook-0.3-py2.6-linux-x86_64.egg
/usr/lib/python2.6/dist-packages/PIL
/usr/local/lib/python2.6/dist-packages/python_amazon_product_api-0.2.5a1-py2.6.egg
/usr/lib/pymodules/python2.6
/usr/local/lib/python2.6/site-packages
/usr/local/lib/python2.6/dist-packages
/usr/lib/python2.6/dist-packages
当对python manage.py shell
做同样的事情时,我会得到相同的列表,但
/usr/lib64/python2.6
丢失。
答案 0 :(得分:1)
您的问题是由于安装了2个“分发”软件包引起的,这可以从提供的蛋黄输出中看出。
答案 1 :(得分:0)
我只是从INSTALLED_APPS中删除了django_pytest。问题现在已经消失。不太好但它有效(tm)。