如何使用Virtualenv运行以前的Python版本?
我的本机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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有帮助吗?
然后使用以下任何一个:
源: htttps:// github .com/pyenv/pyenv-virtualenv#using-pyenv-virtualenv-with-pyenv
Does this help?
Then use either of the following:
Source: https://github.com/pyenv/pyenv-virtualenv#using-pyenv-virtualenv-with-pyenv