ashald / EnvFile

EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
MIT License
533 stars 125 forks source link

Causes ModuleNotFoundError error in PyCharm #222

Open pcauthorn opened 10 months ago

pcauthorn commented 10 months ago

Steps to recreate:

1) Create a project (Proj1) in PyCharm with a new venv. Create module and script (temp.t1.py) that creates a method 2) Create another project (Proj2) in PyCharm and attach it using the same venv as Proj1.
3) Create a script in Proj2 that imports the method 4) Run method and confirm that it works 5) Enable EnvFile in Configurations and rerun to see:

    from temp.t1 import print_hello
ModuleNotFoundError: No module named 'temp'

This error is new as of today

PyCharm 2023.1.4 (Professional Edition)

emunsing commented 10 months ago

I believe I'm also seeing this error, though not in as concisely tested a module: the behavior which I am seeing is that when EnvFile is enabled, python seems to lose awareness of the project source roots. The configured source roots are visible in os.environ['PYTHONPATH'] and sys.path, but do not seem to be traversed by Python when looking for modules (ModuleNotFoundError). Disabling/unchecking EnvFile resolves this issue (but doesn't allow the convenient import of envfile variables)