How to set the python version on the terminal?
已回答
As far as I understand the Python version that's run in the embedded terminal is the one set in the local enviroment, which is different than the one set for the project (the Python interpreter).
The thing is when I run python -v on my cmd (I am on Windows) it displays I am using the 2.7.12 version. However, when running the same command in the PyCharm terminal it's saying I am using the 3.5.2 version. Why is this happening?
How can I set the Python version used in the terminal?
PS: I have tried closing PyCharm in case it was loading the old paths but this issue keeps happening.
请先登录再写评论。
Just to make sure, when you say "embedded terminal", you mean Terminal, not Python Console, correct?
Yes.
Preferences -> Tools -> Terminal doesn't have much configurability, so it is just getting your python from your PATH. You can fiddle with how Windows passes paths into applications such as PyCharm. Or, you can use the Python Console tab:
Good luck.
Since I had set up an alias for Python3 in my MacOS Terminal, it is simple just to switch the default bash shell in Pycharm to zsh.
Preference --> Tools --> Terminal --> Application Settings --> Shell path: select the zsh path, "/bin/zsh", click "Apply" and "OK".
Close the Pycharm and reopen it.
Now you will see the Pycharm terminal use the same z shell setup you have used in MacOS terminal.
Reference:
How to set up MacOS z shell python alias to python3:
1. at your default path: "# cd ~", open ".zshrc" with your favorite editor.
2. Add "alias python=/usr/local//bin/python3" to the file and save.
3. Reload the source profile: "# source ~/.zshrc"
Now you everytime you use "python" it will point to python3.
change shell: "# chsh -s /bin/zsh"