我需要在预先安装了Python 2.3.4的Linux机器上运行一些代码.我不在该机器的sudoers列表中,所以我将Python 2.6.4构建到我的主目录的(子目录)中.然后我尝试使用virtualenv(第一次),但得到了:
$ Python-2.6.4/python virtualenv/virtualenv.py ENV New python executable in ENV/bin/python Could not find platform dependent librariesConsider setting $PYTHONHOME to [: ] Installing setuptools......... Complete output from command /apps/users/dspitzer/ENV/bin/python -c "#!python \"\"\"Bootstrap setuptoo... " /apps/users/dspitzer/virtualen...6.egg: Could not find platform dependent libraries Consider setting $PYTHONHOME to [: ] 'import site' failed; use -v for traceback Traceback (most recent call last): File " ", line 67, in ImportError: No module named md5 ---------------------------------------- ...Installing setuptools...done. Traceback (most recent call last): File "virtualenv/virtualenv.py", line 1488, in main() File "virtualenv/virtualenv.py", line 529, in main use_distribute=options.use_distribute) File "virtualenv/virtualenv.py", line 619, in create_environment install_setuptools(py_executable, unzip=unzip_setuptools) File "virtualenv/virtualenv.py", line 361, in install_setuptools _install_req(py_executable, unzip) File "virtualenv/virtualenv.py", line 337, in _install_req cwd=cwd) File "virtualenv/virtualenv.py", line 590, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command /apps/users/dspitzer/ENV/bin/python -c "#!python \"\"\"Bootstrap setuptoo... " /apps/users/dspitzer/virtualen...6.egg failed with error code 1
我应该将PYTHONHOME设定为某个值吗?(由于缺少一个更好的名字,我故意将我的ENV命名为"ENV".)
不知道我是否可以忽略这些错误,我尝试在我的ENV中安装nose(0.11.1):
$ cd nose-0.11.1/ $ ls AUTHORS doc/ lgpl.txt nose.egg-info/ selftest.py* bin/ examples/ MANIFEST.in nosetests.1 setup.cfg build/ functional_tests/ NEWS PKG-INFO setup.py CHANGELOG install-rpm.sh* nose/ README.txt unit_tests/ $ ~/ENV/bin/python setup.py install Could not find platform dependent librariesConsider setting $PYTHONHOME to [: ] Traceback (most recent call last): File "setup.py", line 1, in from nose import __version__ as VERSION File "/apps/users/dspitzer/nose-0.11.1/nose/__init__.py", line 1, in from nose.core import collector, main, run, run_exit, runmodule File "/apps/users/dspitzer/nose-0.11.1/nose/core.py", line 3, in from __future__ import generators ImportError: No module named __future__
有什么建议?
你真的在你的自定义python构建上运行"make install"吗?通常你会想要做类似的事情
./configure --prefix=/path/to/installdir (other options) make make install
注意前缀可以是您具有完全写入权限的任何目录,例如我经常在共享托管环境中使用$ HOME/apps.
然后运行/ path/to/installdir/bin/python,而不是构建目录中的那个.这应该创建正确的变量,然后你可以安装virtualenv.可能最好使用其setup.py安装virtualenv:
cd virtualenv_source_dir /path/to/installdir/bin/python setup.py install
这可能需要首先使用相同的方法安装setuptools.
最后:
# Just to be safe export PATH="/path/to/installdir/bin:$PATH" virtualenv ~/ENV ~/ENV/bin/pip install somepackage # (and such)