简体   繁体   中英

Windows bash shell shows the wrong version of Python

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.

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.

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