如何使用Virtualenv运行以前的Python版本?

发布于 2025-01-20 03:18:26 字数 936 浏览 3 评论 0原文

我的本机Python安装目前为3.10.2,但是我需要使用的程序仅与2.7-3.8兼容。我没有删除本机安装并安装过时的版本,而是尝试在Virtualenv中运行Python 3.8,但是即使我设置pyenv global 3.8.13,我的Virtualenv中的Python版本仍然3.10 .2。

演示:

设置Global版本

pyenv global 3.8.13

验证

pyenv global

返回

3.8.13

虚拟环境

pyenv virtualenv test 
pyenv activate test
python --version

使

Python 3.10.2

按照此文章的说明我如何将先前版本的python安装到virtualenv中?,我同时安装了pyenv和virtualenv,以及$ home/.pyenv中的python 3.8 /版本文件夹。知道为什么我创建的虚拟环境中不使用此版本吗?

pyenv版本的输出

system
* 3.8.13 (set by $HOME/.pyenv/version)

让我知道我是否可以提供更多细节。

My native python installation is currently 3.10.2, however there is a program I need to use that is only compatible with 2.7-3.8. Rather than deleting my native installation and installing an outdated version, I'm trying to run Python 3.8 in virtualenv, but even when I set pyenv global 3.8.13, the python version in my virtualenv is still 3.10.2.

Demonstration:

set global version

pyenv global 3.8.13

verify

pyenv global

returns

3.8.13

make virtual environment

pyenv virtualenv test 
pyenv activate test
python --version

returns

Python 3.10.2

Following the instructions on this post How do I install a previous version of Python into a virtualenv?, I have both pyenv and virtualenv installed, as well as python 3.8 in the $HOME/.pyenv/versions folder. Any idea why this version isn't being used in the virtual environments that I create?

output of pyenv versions

system
* 3.8.13 (set by $HOME/.pyenv/version)

Let me know if I can provide more detail.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强辩 2025-01-27 03:18:26

这有帮助吗?

pyenv virtualenv 3.8.13 test

然后使用以下任何一个:

cd /path/to/project
pyenv local 3.8.13/envs/test
pyenv activate 3.8.13/envs/test

源: htttps:// github .com/pyenv/pyenv-virtualenv#using-pyenv-virtualenv-with-pyenv

Does this help?

pyenv virtualenv 3.8.13 test

Then use either of the following:

cd /path/to/project
pyenv local 3.8.13/envs/test
pyenv activate 3.8.13/envs/test

Source: https://github.com/pyenv/pyenv-virtualenv#using-pyenv-virtualenv-with-pyenv

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文