试图使用VS Code导入pandas
import pandas
得到
Traceback (most recent call last):
File "c:\Users\xxxx\hello\sqltest.py", line 2, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
试图安装pandas
与
pip install pandas
pip3 install pandas
python -m pip install pandas
分别返回的
(.venv) PS C:\Users\xxxx\hello> pip3 install pandas
Requirement already satisfied: pandas in c:\users\xxxx\hello\.venv\lib\site-packages (1.1.0)
Requirement already satisfied: pytz>=2017.2 in c:\users\xxxx\hello\.venv\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: numpy>=1.15.4 in c:\users\xxxx\hello\.venv\lib\site-packages (from pandas) (1.19.1)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\xxxx\hello\.venv\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: six>=1.5 in c:\users\xxxx\hello\.venv\lib\site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
尝试:
sudo pip install pandas
得到
(.venv) PS C:\Users\xxxx\hello> sudo pip install pandas
sudo : The term 'sudo' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ sudo pip install pandas
+ ~~~~
+ CategoryInfo : ObjectNotFound: (sudo:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我还尝试在this answer之后的工作空间设置下更改python路径。与C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps\python.exe
一起使用,这是我在命令提示符中使用where python
找到的python路径,但是没有用。
然后我尝试
python -m venv .venv
返回了
(.venv) PS C:\Users\xxxx\hello> python -m venv .venv
Error: [Errno 13] Permission denied: 'C:\\Users\\xxxx\\hello\\.venv\\Scripts\\python.exe'
更新:
尝试
python3.8.5 -m pip install pandas
并返回
(.venv) PS C:\Users\xxxx\hello> python3.8.5 -m pip install pandas
python3.8.5 : The term 'python3.8.5' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python3.8.5 -m pip install pandas
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (python3.8.5:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
答案 0 :(得分:2)
这比我们想象的要容易:
这张图片解释了如何解决这个问题。
答案 1 :(得分:1)
https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html 这应该有所帮助。如果没有,请降低投票率。
答案 2 :(得分:1)
解决方案似乎很简单!首先要紧!
通过查看您的帖子,您似乎已经遵循了安装jquery
的指南。没什么错,但我必须首先根据您提供给我们的信息指出,您似乎在运行 Windows Powershell Pandas
和PS C:\Users\xxxx\hello>
。因此,the error format matches Powershell
无法被识别,因为sudo
是sudo
这样的Unix-based
系统的管理命令,这就是为什么它不是有效的命令!
但这是正确安装的方法:(我假设您正在运行Windows,但如果不是这样,请更正我,我会为您提供Unix版本!)
1-Windows键,向上搜索Debian, Ubuntu, and so on
并以CMD
身份运行,这对于避免权限问题很重要!
2-运行administrator
或 pip3 install pandas
答案 3 :(得分:0)
似乎曾经合作过
pip install pandas --user
在命令提示符下。
附加说明:
对于IPython.display
,
pip install IPython--user
在命令提示符下,然后
from IPython.display import display
在VS代码中。
有用的链接: