Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up specific python version for virtual environment for python? [duplicate]

I am a newbie in python and I am trying to add a new environment for my project which runs fine on my current environment Python 3.7.5 After adding all the dependency I was facing an issue for pyttsx3 package(for python text to speech) on researching further I found out that this was a problem with python version Python 3.7.6 https://github.com/nateshmbhat/pyttsx3/issues/136

which was the python version for my current virtual environment. These are the steps that I have followed for install the environment

  1. py -m pip install --user virtualenv
  2. py -m venv env
  3. To activate : .\env\Scripts\activate

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

I want that I can either get Python 3.7.7 or Python 3.7.5(on my current machine) for my virtual environment.

I am using Visual studiocode IDE .

like image 889
Anirudh Thakur Avatar asked Sep 03 '25 03:09

Anirudh Thakur


1 Answers

You can do

virtualenv -p python3.7.5 [name]

but you need to have python3.7.5 in your $PATH or you will get

RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.7.5'

So, you would better use conda

conda create --name [name] python=3.7.5
like image 194
ghchoi Avatar answered Sep 07 '25 18:09

ghchoi