I have created a project and a virtual environment on a machine with PyCharm Professional and Windows 10. Now, I am trying to setup the virtual environment for the same project on another machine still using PyCharm Professional and Windows 10.
I go to Project Interpreter -> Gear symbol -> Add
and then look for the python.exe
file located in venv385\Scripts
. But then I get the following error which is weird since is detecting Python 3.10 while my venv
is Python 3.8.5. How can I solve this?
FYI, there is no base interpreter installed on the second machine. The idea is that I would like to create a project and a venv so that when I will circulate my project, people will not have to install a base interpreter on their machine.
Invalid Python SDK
Cannot set up a python SDK at Python 3.10 (venv 385) (C:\Users...\Python_environment\venv385\Scripts\python.exe). The SDK seems invalid.
There are several problems, a venv should have a base installation to share the standard library (although the venv has its own interpreter). When moving a Python project from one machine to another the venv should be recreated locally (some of its internal paths are fixed and do not update by themselves - you'll break the venv by moving it). The error you are showing can have a number of causes, I don't think it's possible to diagnosing in detail the exact cause without more information.
However, an educated guess would be the venv itself became out of sync with the base installation, see PEP 405. Or the IDE's configuration of the SDK was broken by moving the project or the venv, see this thread.
Also notice that the native Python installation that comes bundled with Windows is not the same as the full development installation you normally use. Carefully read the list about the 3 kinds of packages on the top of the page. And this has changed over time, on older Windows machines there might not even be a Python installed, so you'll need to install the interpreter from scratch.