我想在我没有root权限的Linux机器上安装virtualenv。我在nettuts(http://net.tutsplus.com/tutorials/python-tutorials/python-power-tools-virtualenv/)看到了截屏视频,并尝试按照步骤操作,但收到以下错误。
感谢任何帮助。
/home/x01010/python/virtualenv-1.9.1 > which python
/opt/xpyv/bin/python
/home/x01010/python/virtualenv-1.9.1 > python virtualenv.py foo
PYTHONHOME is set. You *must* activate the virtualenv before using it
Traceback (most recent call last):
File "virtualenv.py", line 2577, in <module>
main()
File "virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "virtualenv.py", line 1081, in create_environment
site_packages=site_packages, clear=clear))
File "virtualenv.py", line 1289, in install_python
writefile(site_filename_dst, SITE_PY)
File "virtualenv.py", line 445, in writefile
f = open(dest, 'wb')
IOError: [Errno 2] No such file or directory: 'foo/lib/python26.zip/site.py'</module>
由于
答案 0 :(得分:0)
问题是,如果设置了PYTHONHOME,则无法创建virtualenv。
如果您正在使用自定义python构建,则应该安装它(您可以使用--prefix将其安装在不需要root访问权限的地方)并运行:
/path/to/install/bin/python virtualenv.py foo
答案 1 :(得分:0)
创建后必须激活虚拟环境。
virtualenv --no-site-packages </path/to/new/environment>
source </path/to/new/environment>/bin/activate
激活虚拟环境后尝试。