Should I pip install python inside virtualenv?

1.9k views Asked by At

I need python3.6 for tensorflow installation, so I downloaded python3.6.12.tar. And I found that I should pip install tarfile. However, in this case it is an older version of python. FYI, In my computer(laptop) I installed python3.9. My question is: can I pip install python.tar inside a virtualenv?

1

There are 1 answers

0
BcK On BEST ANSWER

This is not how virtual environments work. I suggest you to do a little bit more research on virtual environments in Python.

Virtual Environments and Packages

Basically you need to install the necessary python version onto your machine. Then go ahead and use that specific python (which is version 3.6 in your case), to create a virtual environment with the command

~ /usr/bin/<path-to-python3.6> -m venv venv

This command will create a folder called venv. Now you need to source the activation script inside this folder to activate your environment.


Handy note: if you are dealing with different versions of python, a more robust way of handling such situations is via using a tool called pyenv.