Tôi đang gặp trục trặc khi xoắngói Python không cài đặt trong virtualenv sử dụng pip
pip --version
pip 1.1 from /home/chris/GL/GLBackend/glenv/lib/python2.7/site-packages/pip-1.1-py2.7.egg (python 2.7)
Tạo một môi trường ảo
[email protected] ~/GL/GLBackend $ sudo virtualenv -p python2.7 glenv
Running virtualenv with interpreter /usr/bin/python2.7 New python executable in glenv/bin/python2.7 Also creating executable in glenv/bin/python Installing distribute.............................................................................................................................................................................................done. Installing pip...............done.
Chỉ trong trường hợp Tôi sẽ e vững tất cả các quyền
[email protected] ~/GL/GLBackend $ sudo chmod -R 777 glenv
[email protected] ~/GL/GLBackend $ source glenv/bin/activate
(glenv)[email protected] ~/GL/GLBackend $ pip freeze
argparse==1.2.1 distribute==0.6.24 wsgiref==0.1.2
xoắn không được liệt kê ở đây là cài đặt
(glenv)[email protected] ~/GL/GLBackend $ sudo pip install twisted
Requirement already satisfied (use --upgrade to upgrade): twisted in /usr/local/lib/python2.7/dist-packages Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /usr/local/lib/python2.7/dist-packages (from twisted) Requirement already satisfied (use --upgrade to upgrade): distribute in /usr/local/lib/python2.7/dist-packages (from zope.interface>=3.6.0->twisted) Cleaning up... (glenv)[email protected] ~/GL/GLBackend $ pip uninstall twisted Cannot uninstall requirement twisted, not installed Storing complete log in /home/chris/.pip/pip.log
Nhưng khi tôi cài đặt nó nó nói rằng nó đã được cài đặt. Buộc cài đặt:
sudo pip install -I twisted
Downloading/unpacking twisted Downloading Twisted-12.3.0.tar.bz2 (2.6Mb): 2.6Mb downloaded Running setup.py egg_info for package twisted . . .
Successfully installed twisted zope.interface distribute Cleaning up...
Tuy nhiên nó vẫn không được cài đặt
(glenv)[email protected] ~/GL/GLBackend $ pip freeze
argparse==1.2.1 distribute==0.6.24 wsgiref==0.1.2
** Khi tôi cố gắng chạy script Python mà sử dụng xoắn, tôi nhận được một lỗi nói rằng xoắn không được cài đặt. Đó là:
ImportError: No module named twisted.python**
Tại sao bạn sử dụng 'sudo' bằng' pip install' trong 'virtualenv'? Tôi không biết chắc chắn rằng 'pip' cố gắng cài đặt vào hệ thống (nghĩa là, đặt vẫn trong'/usr/local/lib/python2.7', như bạn thấy, thay vì '~/glenv ', như bạn muốn) khi bạn sử dụng' sudo', nhưng ít nhất cũng hợp lý. (Bạn cũng không nên sử dụng 'sudo' để tạo venv của mình ngay từ đầu.) – abarnert
@abarnert đã trả lời bạn và dường như bạn đang gặp sự cố tương tự như http://stackoverflow.com/q/14665330/565999 –