I have installed Pycharm 2016.3 and installed two version of Python (3.5.2 and 2.7.9) on Windows.
I would like to use both of these version, so I configured it at the Project Interpreter window. I chose the 3.5.2 version like the image below
After that I opened the Python Console, everything works fine with the 3.5.2 version of Python. But when I open the Terminal and press python --version
, the version was still not changed.
I couldn't run the server with the statement python manage.py runserver
because the project contains some code which could only be ran in Python 3.x, not 2.x.
How can I fix this problem? Thank you so much
PyCharm Terminal is your local system terminal, as it can be seen in the official PyCharm website.
So you need to make sure that your local python, points to the python setup version you want.
For Linux, something like that:
alias python=/usr/local/bin/python3.5
For Windows you may find helpful this discussion.
The terminal which you mention is actually the Windows Command Prompt, so it won't use the settings that you specified in Pycharm. Think of it as a shortcut to the windows cmd.
Regarding the code compatibility between Python 2.x and 3.x, if the developer does use some Python 2.x code alongside Python 3.x code within the same project, then they should import a package known as 'Future', so the Python 2.x syntax works in Python 3.x. If they haven't then you'll need to make the necessary changes...