简体   繁体   中英

Two versions of python in one computer

I have Pyhton 3.8 (32-bit) in my computer, I use Pycharm and also jupyter notebook. I need to install Python 3.6 (64-bit) because I need to work with tensorflow and it only works with Python 3.6(64-bit)

Can I have two versions of python together? And How can change and work with two python versions in pycharm and jupyter?

Yes you can have multiple Python versions. You can add dependency like python3.6 .

You can also use pyenv . It provides excellent facility to manage various python versions on your machine.

The preferred way to use python virtual environments now is venv .

You can install any number of python versions on your windows, though please also install the py launcher that it comes with. This makes it easy to launch whichever python version you want through the commandline, with no need to rely on PATH nonsense.

If you've the py launcher you can simply launch your desired python version using-

py -3.6-64

The above will launch the 64 bit version of python 3.6 (if installed).

Now, you'll also want to use a virtual env and point pycharm to the venv. To make a venv , go to your project directory (preferably) and do-

> py -3.6-64 -m venv name_of_venv

This will make a venv named of name_of_venv in your project directory and the python version will be 3.6 64 bit.

Now whenever you need to do any python commands, you no longer need to do py -version , you can just do python and even use pip - BUT before that, you need to activate the venv

> & '.\name_of_venv\Scripts\Activate.ps1'

Now you can do normal python operations as long within this venv and it'll all target 3.6 64 bit (or any other version you choose to build the venv with).

To deactivate (though you don't really have to) - you can just type deactivate in the terminal.

Pycharm can be configured with this venv as simply as just pointing to it. You simply have to go to Add python interpreter and choose Virtualenv Environment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM