简体   繁体   English

Pandas 在 Visual Studio 代码中找不到,即使它肯定在环境中

[英]Pandas not found in Visual Studio Code even though it is definitely in the env

I am running Visual Studio Code on two machines, both set up essentially the same way.我在两台机器上运行 Visual Studio Code,两者的设置方式基本相同。 One is an iMac, the other a MacBook Air.一个是 iMac,另一个是 MacBook Air。 In one of my projects, on the iMac, it doesn't recognize that pandas is installed, even though it is in the environment.在我的一个项目中,在 iMac 上,它无法识别 pandas 已安装,即使它在环境中也是如此。

Here is the VSC python interpreter selection:这是 VSC python 解释器选择:

在此处输入图像描述

And here you can see that:在这里你可以看到:

  1. it is not able to import pandas它无法导入 pandas
  2. I'm in the env我在环境中
  3. pip3 freeze shows pandas pip3 冻结显示 pandas
  4. pip3 install indicates that pandas is already present pip3 install 表示 pandas 已经存在

在此处输入图像描述

I've tried uninstalling pandas and reinstalling it, but that doesn't help.我试过卸载 pandas 并重新安装它,但这没有帮助。 I've tried making sure it's in the non-env python install (it is), but that doesn't help.我试过确保它在非环境 python 安装中(它是),但这没有帮助。

I have other projects on the same computer set up essentially the same way, and pandas works fine.我在同一台计算机上的其他项目的设置方式基本相同,并且 pandas 工作正常。 I also have the same project on my laptop, with the same setup, and it is working there too.我的笔记本电脑上也有相同的项目,具有相同的设置,它也在那里工作。 I'm kinda stumped.我有点难过。 I guess I'll be working on it on the laptop for now, but I'd appreciate any insight people may have...我想我现在会在笔记本电脑上处理它,但我会很感激人们可能有任何见解......

Edits编辑

  • if I run the code directly in the terminal, using the venv, it works fine如果我直接在终端中运行代码,使用venv,它工作正常
  • pip3 shows pandas 1.1.1 in the terminal; pip3 在终端显示 pandas 1.1.1; still haven't figured out whether I can get VSC to show me what it's seeing.仍然没有弄清楚我是否可以让 VSC 向我展示它所看到的内容。
  • I figured out how to call pip from inside Python, and when I call this code from inside VSC it doesn't show pandas, but if I call it (python3 test.py) from the terminal, it does.我想出了如何从 Python 内部调用 pip,当我从 VSC 内部调用此代码时,它不显示 Z3A43B4F88325D94022C0EFA9C2FA32F5AZ,但如果我从终端调用它(从 python 测试它)。 So, clearly, I have to figure out why VSC isn't actually using the right environment.所以,很明显,我必须弄清楚为什么 VSC 实际上没有使用正确的环境。
import pip

pip.main(["freeze"])
  • this is getting even stranger;这变得更加陌生了; at @jillcheng's suggestion, I looked in the actual env directory and it doesn't have the package installed.在@jillcheng 的建议下,我查看了实际的 env 目录,它没有安装 package。 This jives with the problem and the above test (running pip freeze from inside py code):这解决了问题和上述测试(从内部 py 代码运行 pip freeze): 在此处输入图像描述
  • it does NOT, however, match up with the fact that if I activate the environment from the terminal window, it shows the package, as shown in the earlier screenshot.但是,它不符合以下事实:如果我从终端 window 激活环境,它会显示 package,如前面的屏幕截图所示。

Thank you!谢谢! Dylan迪伦

According to your description, it is command that you could refer to the following steps:根据您的描述,可以参考以下步骤的命令:

  1. Enter the current virtual environment in VSCode.在 VSCode 中输入当前的虚拟环境。

  2. Enter ' pip --version ' to check if the pip currently used is from the current environment: (This ensures that using pip to install pandas module will be put into the current virtual environment.) Enter ' pip --version ' to check if the pip currently used is from the current environment: (This ensures that using pip to install pandas module will be put into the current virtual environment.)

在此处输入图像描述

  1. List of pips before installing pandas module: (There is no module pandas in the list.)安装 pandas 模块之前的点子列表:(列表中没有模块 pandas。)

在此处输入图像描述

After installation:(I use the command ' pip install pandas '(windows10), mac: pip3 install pandas )安装后:(我使用命令' pip install pandas '(windows10), mac: pip3 install pandas

在此处输入图像描述

  1. If it still has wavy lines, try reloading vscode.( Ctrl+Shift+p , Developer: Reload windows ).如果它仍然有波浪线,请尝试重新加载 vscode。( Ctrl+Shift+pDeveloper: Reload windows )。 The module pandas can be used:模块 pandas 可以使用:

    在此处输入图像描述

  2. Check the installation package:检查安装package:

    If the pip list shows the pands module, but we still can't use it, we can find the current virtual environment folder and check whether there is pandas installation package:如果pip列表显示了pands模块,但还是不能使用,可以找到当前虚拟环境文件夹,查看是否有pandas安装ZEFE90A8E604A7C840E88D03A67F6B7D8:

    在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 表示即使安装了 psutil 模块也未找到 - Visual studio says psutil module not found even though it's installed 即使安装了 Matplotlib 也不会导入。 使用视觉工作室代码 - Matplotlib will not import even though it is installed. Using visual studio code 即使未安装,Visual Studio Code 也会尝试激活 conda base - Visual Studio Code tries to activate conda base even though it is not installed Python:即使它肯定存在,也不会在列表中找到字符串 - Python: will not find a string in a list even though it definitely is there 即使已安装 Pandas 模块也未找到 - Pandas Module Not Found even though it's installed 我在 Visual Studio 代码编辑器中使用 pandas (python) 导入数据集,但即使我的语法正确,它也会给出错误消息 - I am importing the data set using pandas (python) in visual studio code editor but its giving an error message even though my syntax is correct Visual Studio Code - 即使安装了 Intellisense,它也无法在 SSH 服务器上运行 - Visual Studio Code - Intellisense not working on SSH server even though it's installed Visual Studio Code Python:快速打开$ VIRTUAL_ENV中的文件 - Visual Studio Code Python: Quick open a file in $VIRTUAL_ENV Visual Studio Code 中的 IntelliSense 无法正确识别 .env Python 语法 - .env Python syntax not properly recognized by IntelliSense in Visual Studio Code Visual Studio Code Python Interactive Window env 与所选不同? - Visual Studio Code Python Interactive Window env different from selected?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM