Reputation: 588
I have installed python version 2 and 3 in windows 10 through anaconda package. Using python --version
, CMD shows the version of python as 3
, but Windows bash
shell shows it as 2
.
How can I activate python version 3 in Windows bash shell?
I need to activate it because I want to run commands in shell, for instance pyinstaller. CMD does not recognize pyinstaller.
Upvotes: 0
Views: 1507
Reputation: 653
bash in Windows runs on the Windows Subsystem for Linux, which has a version of Ubuntu running on it. It has its own filesystem and its own libraries and binaries for Python, so it is not using the versions of Python you installed in Windows. You can see this by typing which python
in bash. It will return /usr/bin/python
which is a location in the Subsystem for Linux filesystem, not in the normal Windows filesystem.
In bash (as in Ubuntu) you launch Python 2 with the command python
and you launch Python 3 with the command python3
.
If Python 3 is not present in your bash install, you can add it from the package repositories by running the command sudo apt install python3
in bash.
Upvotes: 3