我想使用pipenv shell
运行一个Django项目。但是当我输入pipenv shell
命令时,它失败了。
❯ pipenv shell
Creating a virtualenv for this project…
Pipfile: /Users/juyeong/Desktop/django_workspace/Pipfile
Using /usr/local/bin/python3 (3.7.3) to create virtualenv…
⠸ Creating virtual environment...Already using interpreter /usr/local/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.7'
Running virtualenv with interpreter /usr/local/bin/python3
✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]: File "/usr/local/lib/python3.7/site-packages/pipenv/cli/command.py", line 390, in shell
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=state.pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 2156, in do_shell
[pipenv.exceptions.VirtualenvCreationException]: three=three, python=python, validate=False, pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]: File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]: File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]: extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]: Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 417, in copyfile
os.symlink(os.path.realpath(src), dest)
FileExistsError: [Errno 17] File exists: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin' -> '/Users/juyeong/.local/share/virtualenvs/django_workspace-CfQ2tbWB/lib/python3.7/config-3.7m-darwin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 2611, in <module>
main()
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 862, in main
symlink=options.symlink,
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 1137, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 1421, in install_python
copy_required_files(stdlib_dir, lib_dir, symlink)
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 1331, in copy_required_files
copyfile(join(src_dir, fn), join(lib_dir, fn), symlink)
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 420, in copyfile
copy_file_or_folder(src, dest, symlink)
File "/usr/local/lib/python3.7/site-packages/virtualenv.py", line 398, in copy_file_or_folder
shutil.copytree(src, dest, symlink)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 321, in copytree
os.makedirs(dst)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/Users/juyeong/.local/share/virtualenvs/django_workspace-CfQ2tbWB/lib/python3.7/config-3.7m-darwin'
Failed to create virtual environment.
在使用macOS Mojave时,我使用
pipenv shell
一切都正常,现在我使用的是Catalina版本10.15.1
,但是完全不起作用。我尝试过升级pip、删除和重新安装pipenv,但仍然出现同样的问题。有没有人能帮我解决这个问题呢?附言:我想使用
pipenv shell
虚拟环境,而不是python -m venv
。
rm -rf /Users/juyeong/.local/share/virtualenvs/django_workspace-CfQ2tbWB/
手动删除它。 - arshbot