pipenv shell
命令无法创建虚拟环境。我尝试重新安装 Pipenv 但这对我不起作用。
C:\Users\Shubh\Desktop\projects\pystart>pipenv lock
Creating a virtualenv for this project...
Pipfile: C:\Users\Shubh\Desktop\projects\pystart\Pipfile
Using C:/Users/Shubh/AppData/Local/Programs/Python/Python38/python.exe (3.8.3) to create virtualenv...
[ =] Creating virtual environment...RuntimeError: failed to build image setuptools, wheel because:
Traceback (most recent call last):
File "c:\users\shubh\appdata\local\programs\python\python38\lib\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 55, in _install
if not installer.has_image():
File "c:\users\shubh\appdata\local\programs\python\python38\lib\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 143, in has_image
return self._image_dir.exists() and next(self._image_dir.iterdir()) is not None
StopIteration
Traceback (most recent call last):
File "c:\users\shubh\appdata\local\programs\python\python38\lib\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 57, in _install
installer.install(creator.interpreter.version_info)
File "c:\users\shubh\appdata\local\programs\python\python38\lib\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 46, in install
for name, module in self._console_scripts.items():
File "c:\users\shubh\appdata\local\programs\python\python38\lib\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 116, in _console_scripts
entry_points = self._dist_info / "entry_points.txt"
File "c:\users\shubh\appdata\local\programs\python\python38\lib\site-packages\virtualenv\seed\embed\via_app_data\pip_install\base.py", line 103, in _dist_info
raise RuntimeError(msg) # pragma: no cover
RuntimeError: no .dist-info at C:\Users\Shubh\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.36.2-py2.py3-none-any, has wheel
Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.
谁能帮我解决这个问题吗?
删除这两个文件夹然后运行
pipenv shell
为我解决了这个问题。
C:\Users\<Username>\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.36.2-py2.py3-none-any
C:\Users\<Username>\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-51.0.0-py3-none-any
不确定这是否对您的情况有帮助,因为我的屏幕阅读器没有阅读整个消息,但我只是导入了一个新的配置文件,它解决了问题
就我而言,我同时拥有 python 3.11 和 python 3.10,当我尝试使用 3.10 版本的 pip 安装 pipelinenv 时,pip 使用的是我安装 3.11 版本的 pipeline 时下载的 setuptools 和wheel 的缓存版本。
更新setuptools和wheel解决了这个问题。
您可以使用virtualenv代替pipenv来创建虚拟环境。
检查下面的链接来安装并了解 virtualenv 的使用:-
https://dev.to/serhatteker/how-to-install-virtualenv-on-ubuntu-18-04-2jdi
安装 virtualenv 后,您可以像这样创建 env:-
virtualenv your_env_name -p python3 # use for python3
你还可以编写特定版本的python3,如python3.5或python3.7
virtualenv your_env_name -p python2
# 用于 python2