gpt4 book ai didi

python - 设置虚拟环境 : No module named 'pip'

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

我在 Windows Server 2008 R2 机器上全新安装了 Python 3.3.4。我已经在全局范围内成功安装了最新版本的 Setuptools、Pip 和 Virtualenv:

python ez_setup.py
easy_install pip
pip install virtualenv

现在,当我尝试使用 virtualenv ENV 设置 virtualenv 时,我得到以下堆栈跟踪:

New python executable in ENV\Scripts\python.exe
Installing setuptools, pip...
Complete output from command [path redacted]\ENV\Scripts\python.exe -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'pip'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "C:\Python33\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python33\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File "C:\Python33\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "C:\Python33\lib\site-packages\virtualenv.py", line 824, in main
symlink=options.symlink)
File "C:\Python33\lib\site-packages\virtualenv.py", line 992, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "C:\Python33\lib\site-packages\virtualenv.py", line 960, in install_wheel
'PIP_NO_INDEX': '1'
File "C:\Python33\lib\site-packages\virtualenv.py", line 902, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command [path redacted]\ENV\Scripts\python.exe -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1

我以前从未见过这个错误,堆栈跟踪对我来说没有任何意义。我可以从 Python shell 中成功地 import pip。谁能帮我解决这个问题?

更新 当我提供 --system-site-packages 标志时,env 安装成功。

最佳答案

来自 Python bug ticket 的有用解决方法,适用于遇到此问题的任何其他人:

  • 运行 virtualenv venv --no-setuptools
  • 激活该 virtualenv (venv\Scripts\activate)
  • 下载并运行get-pip.py手动安装 pip 和 setuptools 到这个 virtualenv
  • 照常进行

或者,降级到 3.3.3。这应该在 3.3.5 中正确修复

关于python - 设置虚拟环境 : No module named 'pip' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21826859/

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