未找到 Python Visual Studio 代码模块

未找到 Python Visual Studio 代码模块

问题描述:

已安装 Python 3.7.6 并尝试在 Visual Studio Code 中编写代码

Have installed Python 3.7.6 and am trying to write a code in Visual Studio Code

使用:import pikepdf

让我知道 ModuleNotFoundError: No module named 'pikepdf'

但是,我运行pip install pikepdf"并得到:

However, I run "pip install pikepdf" and I get:

要求已经满足:pikepdf in c:\users\ME\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages (1.8.2)要求已经满足:lxml>=4.0 in c:\users\ME\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages(来自pikepdf)(4.4.2)

Requirement already satisfied: pikepdf in c:\users\ME\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages (1.8.2) Requirement already satisfied: lxml>=4.0 in c:\users\ME\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages (from pikepdf) (4.4.2)

我的 Python 安装路径是:C:\Users\ME\AppData\Local\Programs\Python\Python38

My installation path for Python is: C:\Users\ME\AppData\Local\Programs\Python\Python38

尝试更改Python:Python 路径"中的某些内容会导致更多错误.

And trying to change something in the "Python: Python Path" gets me more errors.

问题是 Visual Studio Code 附带了自己的 Python 版本,而我已经安装了自己的版本.

The issue was that Visual Studio Code comes with its own version of Python, while I had installed my own.

通过更改 VSC 运行的版本,使其与安装模块的版本相匹配,该问题已得到解决.

The issue was solved by changing the version VSC was running so it matched the one where the modules were being installed.