[英]I get this error ( ModuleNotFoundError: No module named 'pandas' ) even though i installed it
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.所以我在我的 mac 上使用 visual studio 代码,我正在尝试运行 python 代码,但我在安装库时一直遇到问题。 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).这是因为您的 pandas 已安装在 anaconda 环境而不是基础环境中(您使用基础 python 解释器运行代码)。
Use shortcuts "Ctrl+Shift+P" and type "Python: Select Interpreter" to choose the correct interpreter.使用快捷键“Ctrl+Shift+P”并输入“Python: Select Interpreter”来选择正确的解释器。
deactivate env_name
or open a new terminal window and install this package by using command 'pip install pandas'deactivate env_name
或打开一个新终端 window 并使用命令“pip install pandas”安装此 package
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.