nil*_*ore 19 python visual-studio-code
pandas尝试在 VS Code 中导入
import pandas
Run Code Online (Sandbox Code Playgroud)
并得到了
Traceback (most recent call last):
File "c:\Users\xxxx\hello\sqltest.py", line 2, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Run Code Online (Sandbox Code Playgroud)
pandas尝试安装
pip install pandas
pip3 install pandas
python -m pip install pandas
Run Code Online (Sandbox Code Playgroud)
分别返回的
(.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)
Run Code Online (Sandbox Code Playgroud)
尝试过:
sudo pip install pandas
Run Code Online (Sandbox Code Playgroud)
并得到了
(.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
Run Code Online (Sandbox Code Playgroud)
我还尝试按照此答案更改工作区设置下的 python 路径。其中C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps\python.exe是我在命令提示符中找到的 python 路径,where python但没有工作。
然后我尝试了
python -m venv .venv
Run Code Online (Sandbox Code Playgroud)
返回的
(.venv) PS C:\Users\xxxx\hello> python -m venv .venv
Error: [Errno 13] Permission denied: 'C:\\Users\\xxxx\\hello\\.venv\\Scripts\\python.exe'
Run Code Online (Sandbox Code Playgroud)
更新:
尝试过
python3.8.5 -m pip install pandas
Run Code Online (Sandbox Code Playgroud)
并返回
(.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
Run Code Online (Sandbox Code Playgroud)
conda install ipykernel。它将安装所有必需的软件包。问题(至少在我的情况下)是我在默认 Python 版本下安装了一个包,但我在 Visual Studio Code (VS Code) 中为不同的 Python 版本设置了解释器。有 2 个选项可以解决此问题。
安装注意事项:以下命令(在命令提示符中)对我有用:pip3 install pandas --user
小智 1
解决方案看起来相当简单!首先,先做事!
从您的帖子来看,您似乎已经按照指南安装了Pandas. 这没有什么问题,但我必须首先指出,根据您提供给我们的信息,您似乎运行Windows Powershell PS C:\Users\xxxx\hello>和the error format matches Powershell. 因此,sudo无法识别,因为它是类似系统sudo的管理命令,这就是为什么它不是有效命令!Unix-basedDebian, Ubuntu, and so on
但正确安装的方法如下:(我假设您运行的是 Windows,但如果情况并非如此,请纠正我,我会给您 Unix 版本!)
1 - Windows 密钥,搜索CMD并运行它,因为administrator这对于避免权限问题很重要!
2 - 运行pip3 install pandas 或 python3 -m pip3 install pandas
| 归档时间: |
|
| 查看次数: |
129703 次 |
| 最近记录: |