I started using Spyder recently. I have Python 3.7 and 3.11 installed in my machine. I want to use the second one (3.11), therefore, I have successfully (confirmed by checking in console sys.path
) adjusted the interpreter in the preferences:
Nevertheless, when I want to install a package using pip
in Spyder’s console (!pip install NAME
), the pip under Python 3.7 is utilized, and the package is installed in the Lib folder of Python 3.7:
Is if it is possible to use the pip version installed under Python 3.11 interpreter in Spyder’s console for installing the desired modules?
At first sight it might be difficult to identify the problem. Try these different things to check if it is all ok. If something’s wrong, don’t doubt in posting what’s wrong:
Firstly, Verify the Python 3.11 Enviroment
You can do that by running in the console the following commands:
path_to_python_3_11/python.exe -m ensurepip
and
path_to_python_3_11/python.exe -m pip install --upgrade pip
Obviously, change the “path_to_python” to your actual path.
If it is all allright, try using the correct pip in Spyder:
Open Spyder and go to the IPython console. Then, instead of using !pip install, use the full path to the pip executable of Python 3.11, such as
!C:/Users/YourUsername/AppData/Local/Programs/Python/Python311/Scripts/pip.exe install (package_name)
.
If nothing works, you should reconsidere using a virtual enviroment.
Hope this helps!
The reason was that Python 3.7 was the default one as its path was prioritized in the environment variables. By setting 3.11 as the default like in the following image and rebooting, fixes the issue.