Bizzare Virtual Environment Behavious - Terminal is fine but run/debug in PyCharm fails

When I try to run the code through PyCharms run/debug function it fails to find the installed modules. PyCharm itself is fine, it doesn't complain about missing modules and the environment appears to be fine.

When I run the exact same command in the Terminal it works without issue.

This happens for both pipenv and venv created environments, whether in PyCharm or externally.

PyCharm Pro 2020.3.3

Linux Mint 20.1

virtualenv 20.0.17 from /usr/lib/python3/dist-packages/virtualenv/__init__.py

pipenv, version 11.9.0 from /usr/bin/pipenv

When running/debugging in PyCharm...

When running the exact same command from the terminal...

I haven't tried conda but I assume the same behaviour.

I have removed all other interpreters and disabled the local versions python from the environment to ensure there are no conflicts.

I have no idea what might be causing this.

 

0
2 comments

After testing briefly I found the problem is the name of the file I am running. It can be recreated by adding a file called site.py to the root of your project.

Example: https://github.com/Stedders/JetBrains_PyCharm_360010498480

How weird.

0

Hello, 

 

it looks like the following bug https://youtrack.jetbrains.com/issue/PY-23615 , please vote for it in order to be updated once it is resolved. 

I apologize for the inconvenience.

0

Please sign in to leave a comment.