我已经使用pyvenv-3.4安装了虚拟环境,它没有安装pip,我无法将任何模块安装到虚拟环境中
(py34devel) x@x-Latitude-E6400:~/venv/py34devel$ ls bin
activate activate.csh activate.fish python python3 python3.4
如果我使用pip,它会回退到虚拟环境之外的默认点,并告知该需求已经满足
(py34devel) x@x-Latitude-E6400:~/venv/py34devel$ pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local
/lib/python2.7/dist-packages
Cleaning up...
我之前使用make altinstall安装了Python3.4,然后我尝试安装请求。
然后我尝试下载并运行get-pip.py,但它给出了以下错误
(py34devel) x@x-Latitude-E6400:~/venv/py34devel$ python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20479, in <module>
main()
File "get-pip.py", line 20471, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 20411, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
所以我用--with-zlib重新配置了Python3.4并再次安装它但是我得到了同样的错误
我尝试使用virtualenv -p python3.4创建虚拟环境,但它再次给出zlib错误
x@x-Latitude-E6400:~/venv$ virtualenv -p python3.4 phere
Running virtualenv with interpreter /usr/local/bin/python3.4
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 17, in <module>
import zlib
ImportError: No module named 'zlib'
有人可以帮忙解决这个问题。
我需要安装一个有python3.4和pip的虚拟环境,所以我可以安装模块,文档说pip是默认安装但不是这里的情况
Unless the --without-pip option is given, ensurepip will be invoked to bootstrap pip
into the virtual environment.
I am didn't give --without-pip option but still pip isn't installed in the virtual environment
请不要让我使用python brew,因为我想使用pyvenv-3.4或virtualenv来解决这个问题
我还尝试使用python2.7安装virtualenv,然后安装了python3.4起源--prefix = path_to_virtual_environment,安装python3.4并且虚拟环境安装了请求,但python3.4不会导入请求。它会给出错误,即没有名为request的模块存在。
答案 0 :(得分:3)
您提到了--with-zlib
,但之前是否安装了zlib-devel
(或zlib-dev
的开发标题,具体取决于您的发行版)?安装标头并再次运行构建。另外,我建议您同时安装readline-devel
和openssl-devel
。