gpt4 book ai didi

python - 为什么 Pipenv 没有选择我的 Pyenv 版本?

转载 作者:行者123 更新时间:2023-12-04 14:44:41 24 4
gpt4 key购买 nike

我的系统 Python 版本是 3.8.5,但是我使用 pyenv 来管理附加版本 3.6.0,以镜像我的项目部署到的服务器版本。我以前使用 virtualenv + virtualenvwrapper 来管理我的虚拟环境,但我听说过 pipenv 很棒的东西,我想我会试一试。在我尝试使用 Python 3.6.0 之前,一切都很好。流程是这样的:

$ mkdir test_project && cd test_project
$ pyenv shell 3.6.0
$ pipenv install django
Creating a virtualenv for this project…
Pipfile: /home/user/projects/test_project/Pipfile
Using /home/user/.pyenv/shims/python (3.6.0) to create virtualenv…
⠸ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 130ms
creator CPython3Posix(dest=/home/user/.local/share/virtualenvs/test_project-eAvoynKo-/home/user, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/user/.local/share/virtualenv)
added seed packages: pip==20.2.3, setuptools==50.3.0, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment!
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.6.0/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/cli/command.py", line 252, in install
site_packages=state.site_packages
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/core.py", line 1928, in do_install
site_packages=site_packages,
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/core.py", line 580, in ensure_project
pypi_mirror=pypi_mirror,
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/core.py", line 512, in ensure_virtualenv
python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
File "/home/user/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pipenv/core.py", line 986, in do_create_virtualenv
with open(project_file_name, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/share/virtualenvs/test_project-eAvoynKo-/home/user/.pyenv/shims/python/.project'

我遇到了上一个问题 Pipenv not recognizing Pyenv version?并设置环境变量 PIPENV_PYTHON="$PYENV_ROOT/shims/python在我的 .bashrc文件。无济于事。
使用系统 Python 版本 3.8.5 可以完美运行:
$ pyenv install django
Creating a virtualenv for this project…
Pipfile: /home/user/projects/test_project/Pipfile
Using /home/user/.pyenv/shims/python (3.8.5) to create virtualenv…
⠹ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 114ms
creator CPython3Posix(dest=/home/user/.local/share/virtualenvs/test_project-eAvoynKo-/home/user/.pyenv/shims/python, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/user/.local/share/virtualenv)
added seed packages: pip==20.2.2, setuptools==50.3.0, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/user/.local/share/virtualenvs/test_project-eAvoynKo-/home/user/.pyenv/shims/python
Creating a Pipfile for this project…
Installing django…
Adding django to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Building requirements...
Resolving dependencies...
✔ Success!
Updated Pipfile.lock (a6086c)!
Installing dependencies from Pipfile.lock (a6086c)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
更新
虽然我仍然无法识别使用 pyenv shell x.x.x 激活的 python 版本,通过删除 PIPENV_PYTHON环境变量,并使用 pipenv install --python 3.6 创建一个新的 virtualenv pipenv 确实识别安装的 pyenv 版本。

最佳答案

pipenv 不尊重 pyenv localpyenv global ( reference )
也许它也不尊重 pyenv shell我通常做你做的,指定python像pipenv install --python 3.7

关于python - 为什么 Pipenv 没有选择我的 Pyenv 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64189006/

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