3

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 .

Anirudh Thakur
  • 101
  • 1
  • 1
  • 5
  • 2
    Does this answer your question? [Use different Python version with virtualenv](https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv) – Le Minaw Jan 28 '21 at 13:24

1 Answers1

7

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
ghchoi
  • 4,812
  • 4
  • 30
  • 53
  • Thank you, it worked :) – Anirudh Thakur Jan 28 '21 at 18:22
  • If you've got more than one version of python installed, and thinking of creating a virtual environment with a specific version, say you've got python3.8 and python3.9, then you can create a virtual environment like so; `python3.8 -m venv ` – Chukwunazaekpere Sep 26 '21 at 02:12