gpt4 book ai didi

python - 如何使用自定义构建的 Python 创建 virtualenv 环境来解决这个问题?

转载 作者:太空狗 更新时间:2023-10-29 22:17:17 24 4
gpt4 key购买 nike

我需要在装有 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 libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
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 <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "<string>", line 67, in <module>
ImportError: No module named md5
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "virtualenv/virtualenv.py", line 1488, in <module>
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” 因为没有更好的名字。)

不知道我是否可以忽略这些错误,我尝试安装 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 libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from nose import __version__ as VERSION
File "/apps/users/dspitzer/nose-0.11.1/nose/__init__.py", line 1, in <module>
from nose.core import collector, main, run, run_exit, runmodule
File "/apps/users/dspitzer/nose-0.11.1/nose/core.py", line 3, in <module>
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)

关于python - 如何使用自定义构建的 Python 创建 virtualenv 环境来解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2278028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com