I am trying to install various Python packages such as pandas
, numpy
, mlforecast
, xgboost
etc. The issue is I have two Python versions in my VM: 3.11.6 and 3.12.
When I run the command print(sys.version())
I get:
3.11.6
But when I check: !python --version
I get:
3.12.0
And when I lookup the kernelspecs using:
!jupyter kernelspec list
I get:
Available kernels:
python3 C:\Python311\share\jupyter\kernels\python3
And when I check the sys path:
sys.path
['C:\\Users\\myname\\Downloads',
'C:\\Python311\\python311.zip',
'C:\\Python311\\DLLs',
'C:\\Python311\\Lib',
'C:\\Python311',
'',
'C:\\Python311\\Lib\\site-packages',
'C:\\Python311\\Lib]]site-packages\\win32',
'C:\\Python311\\Lib]]site-packages\\win32\\lib',
'C:\\Python311\\Lib]]site-packages\\pythonwin']
Both kernelspec and path point to 3.11. But when I try to install say pandas
pip install pandas
I get:
Error: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python312\\Scripts\\f2py.exe'
Looks like the installation is trying to happen in Python 3.12. Could someone please let me know who to make sure that I am using 3.11, more so because some of the packages are not compatible with Python 3.12 yet, so I need to stick to 3.11.
You should be able to use it with
python3.11 -m pip
However you might want to change alias if you only use 3.11 at the moment. See https://www.baeldung.com/linux/default-python3
You should consider working in a venv especially when you have more than one python version installed. https://docs.python.org/3/library/venv.html
python3.11 -m venv ./VENVPATH
source ./VENVPATH/bin/activate
pip install numpy