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?
Change the Python interpreter in the project settingsPress Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. Expand the list of the available interpreters and click the Show All link. Select the target interpreter.
By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P). Note: If the Python extension doesn't find an interpreter, it issues a warning.
Always type py instead of python when running a script from the command line. Set your preferred default version by setting the PY_PYTHON environment variable (e.g. PY_PYTHON=3.7) . You can see what version of python is your default by typing py .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With