Python3.10源码venv已经改变
我去了个人仓库做一些Python Leetcode,在将Kubuntu升级到22.04之后,我意识到当前的Venv不起作用。
我觉得我需要重新创建VENV。 安装了Python3.10-VENV,但我无法源自并激活它。
实际上,VENV/bin/Activate不再存在。
该文件夹仅包含
python python3 python3.10
我尝试过的三个文件,但没有骰子,
source venv/bin/python3.10
因此自然而然地源venv/bin/Activate无效。想法?
I went to do some python leetcode on a personal repo and after I upgraded my Kubuntu to 22.04 I realized the current venv wasn't working.
I had figured I would need to recreate the venv.
Installed python3.10-venv but I cant source and activate it.
In fact venv/bin/activate doesn't exist anymore.
The folder only contains three files
python python3 python3.10
I had tried but no dice
source venv/bin/python3.10
So naturally source venv/bin/activate doesn't work. Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我安装了 Ubuntu 22.0.4,遇到了和你一样的问题,我用这种方式解决了这个问题。
安装 venv:
sudo apt-get update
sudo apt-get install python3-virtualenv
创建 venv:
virtualenv --python=/usr/bin/python3.10 (VENV-NAME)
python3.10 - m venv (VENV-NAME)
源(VENV-NAME)/bin/activate
检查&更新 pip:
pip list
(
/home/amin/Desktop/prog/Django/moein/coffeinrider.com/Project/A/(VENV-NAME)/bin/python3.10 -m pip install --upgrade pip
)I've installed Ubuntu 22.0.4 and I've had the same problem as yours and I solved that problem in this way.
install venv:
sudo apt-get update
sudo apt-get install python3-virtualenv
Create venv:
virtualenv --python=/usr/bin/python3.10 (VENV-NAME)
python3.10 -m venv (VENV-NAME)
source (VENV-NAME)/bin/activate
check & update pip:
pip list
(
/home/amin/Desktop/prog/Django/moein/coffeinrider.com/Project/A/(VENV-NAME)/bin/python3.10 -m pip install --upgrade pip
)当尝试使用
venv
为Python创建虚拟设备时,必须使用已安装的Python版本,但必须使用venv
库的版本系统也必须使用。这是设置虚拟环境的两个先决条件。警告:我急忙这样做是因为我需要它,但请警告:这可能会破坏您的系统python,结果依靠它的应用程序可能会破坏。
我遇到的问题,符合给定的症状在这里,似乎是在尝试使用Python 3.10.8创建
VENV
时,使用了venv
用于Python 3.8.10的模块。因此,给定Python 3.8和Python 3.10已经使用
apt
安装,首先,我卸载了这些软件包:然后我链接
python3
指向Python 3.10:然后我安装了安装的
VENV
for Python3.10:现在意味着为Python 3.8创建虚拟环境不起作用(因为Python3.8
VENV
刚刚删除了)。我不确定是否有一种使它们都起作用的方法,而且我还没有尝试再次安装python3.8-venv
并尝试两者,因为我需要我的3.10环境现在很快工作;-)。但是,在遵循Ubuntu 20内通常的升级路线时,似乎可能引入了一些冲突。但是,Python 3.10的
VENV
现在应该按预期工作:When trying to create a virtual env using
venv
for Python, a version of Python that is already installed system-wide must be used, but a version of thevenv
library from the system must also be used. These are two pre-requisites for setting up a virtual environment.WARNING: I did this in a hurry because I needed it but please be warned: this may break your system Python with a result that applications that rely on it may break.
The problem I had, matching symptoms given here, seems to be that when trying to create a
venv
using Python 3.10.8, thevenv
module for Python 3.8.10 was being used.So, given Python 3.8 and Python 3.10 are already installed using
apt
, first of all I uninstalled these packages:Then I linked
python3
to point to Python 3.10:Then I installed the
venv
for Python3.10:This now means creating a virtual environment for Python 3.8 doesn't work (because Python3.8
venv
has just been removed). I'm not sure if there is a means to have them both working, and I haven't yet tried to just installpython3.8-venv
again and try them both, as I need my 3.10 environment working quickly, right now ;-). But it seems possible there has been some conflict introduced when following the usual upgrade route within Ubuntu 20.However,
venv
for Python 3.10 should now work as expected:它已更新为
source venv/local/bin/activate
It has been updated to
source venv/local/bin/activate