Problem
Code that ran before a PyCharm update no longer runs after it. The source files are unchanged. Imports may be flagged as unresolved for packages that are still installed, and the run configuration may report that no interpreter is set.
Cause
The Python interpreter is a per-project setting. It points at a specific Python installation or virtual environment, and code runs only while that reference resolves. After an update the reference can be missing or invalid, for example when the virtual environment it names was moved, deleted, or recreated. PyCharm then has nothing to run the code with, and imports fail even though the packages are still installed.
Resolution
- Open the project in PyCharm.
- Press Ctrl+Alt+S to open Settings.
- Go to Python | Interpreter.
- Check the interpreter shown. An empty selector, or an entry marked as invalid, confirms the cause.
- Select a valid interpreter from the list.
- If the required interpreter is not listed, click Show All, then select it in the left pane.
- If no valid interpreter exists, click Add Interpreter, then Add Local Interpreter.
- Point it at the Python installation, or create a virtual environment.
- Run the code again.
The status bar has a Python Interpreter selector that opens the same page through Interpreter Settings. Configure a Python interpreter covers each interpreter type in full.
If the interpreter is valid but the packages are missing, the project points at a different environment than the one that holds them. Compare the interpreter path against that environment. Select the environment that holds the packages.
Comments
0 comments
Please sign in to leave a comment.