Home > Enterprise >  Create Virtual Environment with native Python (w/out Conda_
Create Virtual Environment with native Python (w/out Conda_

Time:02-12

Goal: create Python 3.8.8 venv.

  • I've Python 3.8.10 installed
  • Poetry project is Python 3.8.8
  • don't have conda

I tried installing suggested package for creating a venv but this didn't work.

How can I create a Python 3.8.8 venv without conda?

Terminal:

@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'

CodePudding user response:

See one of the links below:

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

But I strongly recommend to use conda for create and manage venv

  • Related