使用本机创建虚拟环境 Python (w/out Conda_

Create Virtual Environment with native Python (w/out Conda_

目标:创建Python 3.8.8 venv.

我尝试安装建议的包来创建 venv,但这没有用。

如何在没有 conda 的情况下创建 Python 3.8.8 venv?

航站楼:

@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ poetry install
The currently activated Python version 3.8.10 is not supported by the project (3.8.8).
Trying to find and use a compatible version. 

  NoCompatiblePythonVersionFound

  Poetry was unable to find a compatible version. If you have one, you can explicitly use it via the "env use" command.

  at ~/.poetry/lib/poetry/utils/env.py:768 in create_venv
       764│                     python_minor = ".".join(python_patch.split(".")[:2])
       765│                     break
       766│ 
       767│             if not executable:
    →  768│                 raise NoCompatiblePythonVersionFound(
       769│                     self._poetry.package.python_versions
       770│                 )
       771│ 
       772│         if root_venv:
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ conda create -n sdg python=3.8.8
conda: command not found
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ python3 -m venv sdg python=3.8
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 install python3.8-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/me/Documents/GitHub/foo/bar/sdg/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ apt install python3.8-venv
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ sudo apt install python3.8-venv
[sudo] password for me: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python3.8-venv
0 upgraded, 1 newly installed, 0 to remove and 68 not upgraded.
Need to get 5452 B of archives.
After this operation, 27.6 kB of additional disk space will be used.
Ign:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3.8-venv amd64 3.8.10-0ubuntu1~20.04.1
Err:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 python3.8-venv amd64 3.8.10-0ubuntu1~20.04.1
  404  Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/p/python3.8/python3.8-venv_3.8.10-0ubuntu1~20.04.1_amd64.deb  404  Not Found [IP: 91.189.88.142 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ virtualenv --python=python3.8.8 sdg
RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.8.8'

查看以下链接之一:

https://python-guide-cn.readthedocs.io/en/latest/dev/virtualenvs.html 要么 https://virtualenv.pypa.io/en/latest/installation.html

但我强烈建议使用 conda 来创建和管理 venv