简体   繁体   English

我收到此错误(ModuleNotFoundError: No module named 'pandas'),即使我安装了它

[英]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”来选择正确的解释器。

  1. You can choose anaconda then run the code.您可以选择 anaconda 然后运行代码。
  2. If you want to run the code in the base python interpreter.如果要在基础 python 解释器中运行代码。 Use command 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.

相关问题 ModuleNotFoundError:即使我安装了功能工具,也没有名为“功能工具”的模块 - ModuleNotFoundError: No module named 'featuretools' even though I have installed featuretools ModuleNotFoundError:没有名为“google.cloud”的模块,即使我安装了它 - ModuleNotFoundError: No module named 'google.cloud' even though I installed it “ModuleNotFoundError:即使安装了模块,也没有名为‘...’的模块 - "ModuleNotFoundError: No module named '…' even though module is installed ModuleNotFoundError:即使已安装,也没有名为“pycountry”的模块 - ModuleNotFoundError: No module named 'pycountry' even though it is installed 即使我安装了它,也没有名为“Kivy”的模块 - No module named 'Kivy' even though I installed it ModuleNotFoundError:即使我安装了 pip 安装 websocket,也没有名为“websocket”的模块 - ModuleNotFoundError: No module named 'websocket' even though I installed pip install websocket ModuleNotFoundError: 没有名为 'imutils' 的模块。 即使我已经安装了 imutils - ModuleNotFoundError: No module named 'imutils' . even though I have install imutils ModuleNotFoundError:没有名为“pandas”的模块 - 当我已经安装了熊猫时 - ModuleNotFoundError: No module named 'pandas' - when I have pandas already installed ImportError:没有名为 qrcode 的模块,即使我安装了模块 - ImportError: No module named qrcode, even though i have the module installed 我安装了一个名为 Discord 的模块,在使用“import discord”时出现错误:“ModuleNotFoundError: No module named 'discord'” - I Installed a Module Called Discord and When Using “import discord” I Get the Error: “ModuleNotFoundError: No module named 'discord'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM