我正在使用virtualenv运行django。由于某些原因,django在/usr/share/qgis/python/httplib2...
中调用httplib2
,因为某些原因有语法错误。在我从arch的AUR安装qgis库之前,这种情况从未发生过。
我不明白为什么要调用qgis中的库?我在virtualenv和文件系统(在错误弹出后安装)中也有相同的库:
[root@arch http]# pacman -Ql | grep httplib2
...
python-httplib2 /usr/lib/python3.4/site-packages/httplib2/
...
这是关于我的虚拟环境的信息:
(app)[jenia@arch merging_map_]$ python --version
Python 3.4.1
(app)[jenia@arch merging_map_]$ pip freeze
Django==1.6.5
Pillow==2.5.1
django-simple-captcha==0.4.2
gunicorn==18.0
httplib2==0.9 <-------------- I installed this after finding the error.
ipython==2.1.0
oauthlib==0.6.3
psycopg2==2.5.3
python-social-auth==0.1.26
python3-openid==3.0.4
requests==2.3.0
requests-oauthlib==0.3.1
six==1.7.3
这是回溯。它有点长,我认为最有趣的是最后几行(堆栈的顶部)。它说django试图使用一个库在/usr/share/qgis...
trace back:
Internal Server Error: /login
Traceback (most recent call last):
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/srv/http/merging_map_/app/zones/views.py", line 185, in my_login
user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password'])
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 47, in authenticate
for backend in get_backends():
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 22, in get_backends
backends.append(load_backend(backend_path))
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 16, in load_backend
return import_by_path(path)()
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/django/utils/module_loading.py", line 21, in import_by_path
module = import_module(module_path)
File "/srv/http/merging_map_/app/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/social/backends/google.py", line 7, in <module>
from social.backends.open_id import OpenIdAuth
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/social/backends/open_id.py", line 1, in <module>
from openid.consumer.consumer import Consumer, SUCCESS, CANCEL, FAILURE
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/openid/consumer/consumer.py", line 194, in <module>
from openid import fetchers
File "/srv/http/merging_map_/app/lib/python3.4/site-packages/openid/fetchers.py", line 26, in <module>
import httplib2
File "/usr/share/qgis/python/httplib2/__init__.py", line 911
print "connect: (%s, %s) ************" % (self.host, self.port)
SyntaxError: invalid syntax
/srv/http/merging_map_/app/lib/python3.4/site.py:429: DeprecationWarning: 'U' mode is deprecated
fp = open(filename, "rU")
那么我该如何修复它呢?我如何使python执行在虚拟环境中的httplib2 ?
提前感谢你的时间和善意的帮助。
Jenia .
编辑1:来自虚拟环境的系统路径:
['', '/srv/http/merging_map_',
'/usr/share/qgis/python', <----------------------- how did this get here?!!!
'/srv/http/merging_map_/app/lib/python34.zip',
'/srv/http/merging_map_/app/lib/python3.4',
'/srv/http/merging_map_/app/lib/python3.4/plat-linux',
'/srv/http/merging_map_/app/lib/python3.4/lib-dynload',
'/usr/lib64/python3.4', '/usr/lib/python3.4',
'/usr/lib/python3.4/plat-linux',
'/srv/http/merging_map_/app/lib/python3.4/site-packages']
我不知道qgis文件夹是如何进入虚拟环境的执行路径的。请告诉我怎么把它弄出来!!以及如何用正确的python路径替换它
所以问题似乎是库在PYTHONPATH中。你可以通过
删除它$ unset PYTHONPATH
$ source /path/to/venv/bin/activate
现在关于它是如何到达那里的:可能你安装了一些东西(QGIS)将它添加到那里。你可以试着在它定义的地方找到它并删除它
$ grep -r "PYTHONPATH" /etc
你也应该检查你的.bashrc
和.profile
文件在你的主文件夹。当然,如果您从python路径中删除该条目,需要它的软件可能会停止工作…