11

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

enter image description here

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.

enter image description here

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?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Linh Văn
  • 121
  • 1
  • 1
  • 4
  • Did you try `python3 manage.py runserver`? – jonrsharpe Dec 20 '16 at 08:22
  • It said "python3 is not recognized as an internal or external command...", but I've just fixed it by rename the executing file in the Python3x folder to python3.exe, then it works! – Linh Văn Dec 20 '16 at 11:07

2 Answers2

3

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.

Community
  • 1
  • 1
afxentios
  • 2,502
  • 2
  • 21
  • 24
  • In addition you can configure the PyCharm Run to actualy take arguments eg. "runserver". See this article https://www.jetbrains.com/help/pycharm/2016.2/creating-and-editing-run-debug-configurations.html for some more information on that. – afxentios Dec 20 '16 at 08:26
-1

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...