gpt4 book ai didi

python - 在 WSL (Ubuntu) 中为 python3 安装 venv

转载 作者:行者123 更新时间:2023-12-03 09:57:09 29 4
gpt4 key购买 nike

我正在尝试配置 venv在带有 Ubuntu 的 Linux 的 Windows 子系统上。

我试过的:

1) 安装venv通过pip (pip3,确切地说)

pip3 install venv

我收到以下错误
ERROR: Could not find a version that satisfies the requirement venv (from versions: none)
ERROR: No matching distribution found for venv

2) 安装 venv通过 aptapt-get
sudo apt install python3-venv

在这种情况下,安装似乎完成了,但是当我尝试使用 python3 -m venv ./venv 创建虚拟环境时,我得到一个错误,告诉我做 apt-get install python3-venv (我刚刚做了!)
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

apt-get install python3-venv

You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/mnt/c/Users/Vicubso/.../code/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

我还阅读了以下帖子
post 1 ,
post 2 ,以及其他几个。这些似乎都不能解决我的问题。

任何帮助将非常感激。

最佳答案

这里没有任何东西对我有用,但这在 WSL2 中有效:

sudo apt-get update
sudo apt-get install libpython3-dev
sudo apt-get install python3-venv
python3.8 -m venv whatever
祝你好运!

关于python - 在 WSL (Ubuntu) 中为 python3 安装 venv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61528500/

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