Two versions of python in one computer

南楼画角 提交于 2021-02-11 18:16:11

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/62428732/two-versions-of-python-in-one-computer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!