so I'm using visual studio code on my mac and I'm trying to run a python code but I keep having problems with installing libraries. whenever i run the code i get this
(base) reema@Reemas-MacBook-Pro-2 ~ % /usr/local/bin/python3 "/Users/reema/Desktop/import pandas as pd.py" Traceback (most recent call last): File "/Users/reema/Desktop/import pandas as pd.py", line 1, in import pandas as pd ModuleNotFoundError: No module named 'pandas'
even though when I install it again it says this
`(base) reema@Reemas-MacBook-Pro-2 ~ % pip install pandas
Requirement already satisfied: pandas in ./opt/anaconda3/lib/python3.8/site-packages (1.4.2)
Requirement already satisfied: pytz>=2020.1 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (2021.1)
Requirement already satisfied: numpy>=1.18.5 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (1.20.1)
Requirement already satisfied: python-dateutil>=2.8.1 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (2.8.1)
Requirement already satisfied: six>=1.5 in ./opt/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.8.1->pandas) (1.15.0)`
This is caused that your pandas has been installed in anaconda environment instead of base environment (you run your code by using base python interpreter).
Use shortcuts "Ctrl+Shift+P" and type "Python: Select Interpreter" to choose the correct interpreter.
deactivate env_name
or open a new terminal window and install this package by using command 'pip install pandas'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.