Different Python version in Terminal and PyCharm despite using the very same venv and path Follow
I'm setting up PyCharm for my app development and have encountered a strange issue. Even though I set my project to use the very same virtual environment (I used the built-in venv) and made sure PyCharm's interpreter points to the same path, the versions of Python are different.
Everything I googled up was someone's not setting the interpreter inside PyCharm correctly. I also checked PyCharm's guide and haven't found anything that I haven't already tried.
These are the results from the Terminal (I'm using Linux Mint 19), inside my venv:
(venv) x:~/Programming/Shopping_Tracker$ python --version Python 3.6.7 (venv) x:~/Programming/Shopping_Tracker$ which python /home/anna/Programming/Shopping_Tracker/venv/bin/python
And these are from PyCharm's Terminal:
(venv) python --version Python 3.7.3 (venv) which python /home/anna/Programming/Shopping_Tracker/venv/bin/python
So the versions should be the same to my understanding.
Has anyone encountered a similar issue?
Please sign in to leave a comment.
Something is definitely wrong with your environment or interpreter.
Please try to delete venv directory, then create a new interpreter with a new virtualenv environment in PyCharm.
Very strange. Never seen such issue before.
Please run the following script from both terminals and post the output:
Hey, so here'e the output from the OS Terminal, outside PyCharm, inside the venv:
'pkg_resources.working_set': [six 1.12.0 (/home/anna/Programming/Shopping_Tracker/venv/lib/python3.6/site-packages),
setuptools 39.0.1 (/home/anna/Programming/Shopping_Tracker/venv/lib/python3.6/site-packages),
python-dateutil 2.8.0 (/home/anna/Programming/Shopping_Tracker/venv/lib/python3.6/site-packages),
pkg-resources 0.0.0 (/home/anna/Programming/Shopping_Tracker/venv/lib/python3.6/site-packages),
pip 9.0.1 (/home/anna/Programming/Shopping_Tracker/venv/lib/python3.6/site-packages)],
'sys.version_info': sys.version_info(major=3, minor=6, micro=7, releaselevel='final', serial=0)}
And unfortunately, the output from the PyCharm Terminal shows this error (same venv is active in PyCharm):
Traceback (most recent call last):
File "<input>", line 3, in <module>
File "/app/pycharm/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'pkg_resources'
When I run your script in PyCharm excluding pkg resources, I get this output:
'sys.version_info': sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)}
I hope it still helps.
I also experienced this issue in Pycharm Community version 2019.2.4. But this issue not exist in version 2019.1.4.
I am getting a very similar issue. I have 4 folders added to a project, and each has its own "venv" because I can also use them separately. The terminal is using the second folder's "venv" instead of the first folder. I want it to use the first folder's "venv" so it's frustrating that it won't do that.
I had the very same issue. In the terminal, it showed python version 3.8 whereas pycharm showed 3.7. Moreover, the paths to the python interpreter (which was set with a virtual environment) were exactly the same. I managed to resolve the problem. In my case the problem was that I installed pycharm as a flatpak (on ubuntu). Uninstalling pycharm and then reinstalling it as suggested on the pycharm website fixed it.
I have the same problem running 2020.3 x64 on Win 10. Everything was fine and the venv was located in the project directory tree. I moved the whole project "down" a directory -- which then broke the full path length to the interpreter. This caused pycharm to barf. I then went in and 'repointed' to the same venv --- in a new directory.
The python console runs the 'correct' venv, but the terminal does not -- it picks up on the systems default.
Terminal should activate the same venv as configured in your project interpreter settings. Does the issue still reproduce if you recreate the interpreter from scratch?
I tried a zillion things, recreating from scratch, rolling back to 2020.1, etc. Finally I stumbled across the answer. Wasn't a bug, just sometime it seems the 'default' for the gui was to have the visibility for the console turned off.
The "obvious" solution was to right click on the word 'Debugger' go to layout and check the Console option which was unchecked.
Frustrating, but at least I figured it out. Not sure why that is off by default.
I had the same problem where i upgraded my boto3 version in command line, but Pycharm still showed old version.
Check if PyCharm has different version than command line :- print('boto3 version :', boto3.__version__)
Fix :- I went to Pycharm - Settings - Python Interpreter settings and was able to see the Boto3 version to the older version. Clicked on update icon and that upgraded boto3 in PyCharm as well