【发布时间】:2020-12-02 21:18:16
【问题描述】:
尝试在 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
【问题讨论】:
-
你试过
python -m pip install pandas吗?还是python3.x -m pip install pandas? -
或者以
python3 file.py运行它? -
嗨@MZ,请查看已编辑的问题;如何以
python3 file.py运行它? -
在终端做python3 sqltest.py
-
我的意思不是字面上的 python3.x。我的意思是 3.(无论你使用什么 python 版本)或者只是 python3