如何更新我在 Visual Studio 代码中使用的 pandas 版本。我认为我的 python 安装设置不正确

How to update the version of pandas that I'm using in Visual Studio code. I think my python installs are setup improperly

我在网上搜索过,但没有找到解决我做错的方法。我想我已经掌握了拼图的所有部分并且知道出了什么问题,但我只是不知道我需要做些什么来解决它。

我开始认为我安装了两个 python,但我没有更新在 VS 代码中使用的安装,而且我更新的 python 安装不正确在 VS 代码中设置。我下载了 anaconda,但我认为 VS 代码 python 扩展是唯一设置正确的扩展。如果我使用 anaconda 提示并遵循一些 posts/solutions 详细信息

import pandas as pd

pd.__version__

我得到了 1.1.3,我相信我前几天在尝试解决我的问题时更新了它。但是,如果我在 VS 代码中使用终端并做同样的事情,我会得到 1.0.5(这是产生我正在处理的问题的 pandas 版本......它在绘制 pandas df).我猜这与未将 anaconda 设置为 PATH 和 VS 代码使用扩展而不是 anaconda 下载有关。为了进一步支持这一点,如果我 select Python 3.7.9 64-bit (conda) 解释器而不是 Python 3.7.9 64-bit 和 运行 通常在非 conda 解释器上运行的代码,我得到以下信息:

 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "C:\Users\user
\anaconda3\python.exe"
  * The NumPy version is: "1.19.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed: The specified module could not be found.

如果我怀疑是问题所在,那么我有点困惑在使用非 conda 解释器时如何导入和使用 pandas、matplotlib 和 Numpy 等包.

有人可以向我解释并引导我朝着正确的方向前进吗?

得到两个不同版本的“pandas”的原因是您使用的 Python 解释器不同。你使用的“Python 3.7.9 64-bit”是你下载安装的python解释器(全局环境),“Python 3.7.9 64-bit (conda)”是Anaconda自带的Python解释器(康达环境)。

根据您提供的终端信息,非conda环境下没有“pandas”的依赖包“numpy”。建议您安装模块“numpy”(pip install numpy)。通常,当安装模块“pandas”时,终端会自动安装它需要的依赖项。因此,您也可以在 VSCode 全局环境中重新安装“pandas”。

如果你想指定某个版本的模块“pandas”,你可以使用“pip install pandas==1.1.3”来安装1.1.3版本。