0

I am working on a python script that would automatically generate a virtual environment with a specific version. As far as I know, you can only create a virtual environment of a python version already installed on the computer. Is there a way around this? For example, I would like to generate a python 3.7 virtual environment although it is not installed on my computer. Thanks

  • Can you please clarify what you are trying to do? Why don't you install the version for which you want a venv? – MisterMiyagi Jun 30 '20 at 20:37
  • Does this answer your question? [Use different Python version with virtualenv](https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv) – Nathan Jun 30 '20 at 20:39
  • 1
    @MisterMiyagi Just because it's a hassle. If I need to create an application with a specific python version, it's really annoying to do a full install of that version. My friend and I are working on image recognition ai and things tend to require very specific python versions to work – Nicholas Carpenedo Jun 30 '20 at 20:40
  • @Nathan Not really because that requires you to have the python version with which you want to make a virtual environment already installed on the pc. Am I missing the point of virtual environments? – Nicholas Carpenedo Jun 30 '20 at 20:41
  • I completely misunderstood your question. @NicholasCarpenedo – Nathan Jun 30 '20 at 20:47
  • 1
    In all honesty, I'd just install the versions 2.4-2.7 and 3.6-3.8 (should be 15 minutes max) and then use the virtual envs (I don't think it's possible to have a virtual env with a python version that you haven't previously installed) – Nathan Jun 30 '20 at 20:49
  • Thank you @Nathan. I might do that. I'm still curious whether it's possible or not. – Nicholas Carpenedo Jun 30 '20 at 21:09

1 Answers1

1

The common way for doing this is by using anaconda, and creating conda environments which let you specify the python version. It is very popular among data scientists and it is used extensively in machine learning because of the many different versions of python and packages you need. Reading your comment about working with AI this is a popular solution to your problem.

To make an enviroment with a specific python after you install use
conda create -n emvname python=3.4

note that you can use conda install package instead of pip for many packages and you should prefer it, pip still works as normal of course.

jimakr
  • 574
  • 3
  • 7