'How can I ensure my Python packages are installed in Python 3.10 instead of /Library/Python 3.8?
I have successfully installed Python 3.10. I want to install packages. Pandas, BeautifulSoup4, and requests.
I tried to import NumPy but IDE says it doesn't have the NumPy module.
I searched for it in directories and it turned out NumPy is in the 3.8 version.
I used the command on the terminal:
sudo python3 -m pip install Pandas
Which installed it successfully.
But the package files are installed in Python 3.8.
Now I have the following Directories:
- /Library/Python 3.8
- /Library/Frameworks/Python.framework/Versions 3.10
- /Applications/Python 3.10
- /usr/local/bin 3.10
In /Library/Python there is only 2.7 and 3.8 versions
In following directories version is 3.10:
- /Library/Frameworks/Python.framework/Versions 3.10
- /Applications/Python 3.10
- /usr/local/bin 3.10
/usr/local/bin
/Library/Frameworks/Python.framework/Versions
/Applications/Python
What will happen if i remove 3.8 or can i update it to 3.10?
Solution 1:[1]
Is better to use a virtual environment and install in it python 3.10, removing Python 3.8 can may some problems, so avoid removing it, and if you are open to using different tools, I advise you to use Jupyter Notebook.
Solution 2:[2]
Don't follow this (go to EDIT instead):
I found my answer here: https://stackoverflow.com/a/25123329/13377578
Just had to specify the version of Python I want to install the package in.
sudo python3.10 -m pip install Pandas
Now it works. Thanks.
EDIT:
Thanks for the comments below. I am new to Python and didn't know what environments were.
I followed this simple guide.
I made an environment for my project (my system-level python is now safe from messing up) and now everything works.
Create Environment:
cd python-projects
Python3.10 - m venv Venv_Name
source pit-ds/bin/activate
Installing Packages:
pip list
pip install Pandas
pip install BeautifulSoup4
pip install Requests
Run IDLE within Virtual Environment:
python -m idlelib.idle
Deactivating Environment:
deactivate
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MohamedAmineSekmani |
| Solution 2 |




