Reputation: 32071
In a run configuration in PyCharm I've check both:
Add content roots to PYTHONPATH
Add source roots to PYTHONPATH
But I can't import files relative to my sources root. This is a new installation of PyCharm (system rebuild) and an existing project & run configurations which worked before now fail.
In the Python Console I print the value of sys.path
and see my content root, but not the source root listed. I double check the Project Structure and see the directory src
is listed as a Source Folder appropriately.
When I run python at the console from the source root directory all imports work as expected.
Any idea what configuration I might be missing in PyCharm to cause this? Or perhaps my expectation is incorrect?
Upvotes: 9
Views: 6720
Reputation: 32071
I found the solution here:
Just delete the .idea
project directory and re-create the project to fix the problem.
Upvotes: 10