尝试使用pandas
VS Code导入
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
我还尝试按照此答案在工作区设置下更改python路径。使用C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps\python.exe
它是我在命令提示符中使用的python路径,where 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
解决方案似乎很简单!首先要紧!
通过查看您的帖子,您似乎已经遵循了安装指南Pandas
。这没什么不妥,但是我必须首先根据您提供给我们的信息,您似乎正在运行Windows Powershell PS C:\Users\xxxx\hello>
和the error format matches Powershell
。因此,sudo
不会被识别,因为sudo
对于Unix-based
类似Debian, Ubuntu, and so on
这样的系统,admin命令是无效的命令!
但是,这是正确安装的方法:(我假设您正在运行Windows,但如果不是这样,请更正我,我会为您提供Unix版本!)
1-Windows键,搜索CMD
并运行它,因为administrator
这对于避免权限问题很重要!
2-运行pip3 install pandas
或 python3 -m pip3 install pandas
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句