gpt4 book ai didi

python - Ubuntu:无法为 python 设置 virtualenv

转载 作者:行者123 更新时间:2023-11-28 21:20:08 25 4
gpt4 key购买 nike

我正在使用 Ubuntu。我试图跟随 Deploying a Django on Amazon Elastic Beanstalk .

我没有使用 yum,而是使用了 apt-get

我很好地遵循了前面的每一步。

root@james-MacBookPro:/home/james# virtualenv --version
1.7.2
root@james-MacBookPro:/home/james# python --version
Python 2.7.6
root@james-MacBookPro:/home/james# apt-get install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
root@james-MacBookPro:/home/james# apt-get install python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.7-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

但是当我尝试为 Django 开发创建虚拟环境时,出现了一些错误。我输入了 virtualenv -p python2.6/tmp/djangodev

root@james-MacBookPro:/home/james# virtualenv -p python2.7 /tmp/djangodev
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /tmp/djangodev/bin/python2.7
Not overwriting existing python script /tmp/djangodev/bin/python (you must use /tmp/djangodev/bin/python2.7)
Installing setuptools...................................
Complete output from command /tmp/djangodev/bin/python2.7 -c "#!python
\"\"\"Bootstra...sys.argv[1:])


" /usr/local/lib/pytho...ols-0.6c11-py2.7.egg:
Traceback (most recent call last):
File "<string>", line 279, in <module>
File "<string>", line 240, in main
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1712, in main
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1716, in <lambda>
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 971, in run_command
cmd_obj.ensure_finalized()
File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 125, in finalize_options
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1121, in _expand
File "/usr/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/command/install.py", line 32, in finalize_options
File "/usr/lib/python2.7/distutils/command/install.py", line 321, in finalize_options
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
File "/tmp/djangodev/lib/python2.7/distutils/__init__.py", line 85, in sysconfig_get_config_vars
real_vars = old_get_config_vars(*args)
File "/usr/lib/python2.7/distutils/sysconfig.py", line 495, in get_config_vars
func()
File "/usr/lib/python2.7/distutils/sysconfig.py", line 439, in _init_posix
from _sysconfigdata import build_time_vars
File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2429, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1052, create_environment
search_dirs=search_dirs, never_download=never_download)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 598, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 570, in _install_req
cwd=cwd)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /tmp/djangodev/bin/python2.7 -c "#!python
\"\"\"Bootstra...sys.argv[1:])



" /usr/local/lib/pytho...ols-0.6c11-py2.7.egg failed with error code 1

谁能告诉我哪里出了问题以及如何解决?

最佳答案

这是由已知的 bug 引起的在Ubuntu中。

修复此问题,在 python2.7 目录中创建模块 _sysconfigdata_nd.py 的软链接(soft link):

cd /usr/lib/python2.7
sudo ln -s plat-x86_64-linux-gnu/_sysconfigdata_nd.py .

(或使用

sudo ln -s plat-i386-linux-gnu/_sysconfigdata_nd.py .

如果你在 i386 系统上)

关于python - Ubuntu:无法为 python 设置 virtualenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23273650/

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