简体   繁体   English

使用 Pip 安装 Python 3.9 后导入模块出错

[英]Errors importing module after using Pip to install with Python 3.9

Apologies, but I'm a total python newbie and I'm really stuck with this.抱歉,但我是一个完全的 python 新手,我真的坚持这一点。 I've got Python 3.9 on a PC, and am learning to code using PyCharm as my editor.我在 PC 上安装了 Python 3.9,并且正在学习使用 PyCharm 作为我的编辑器进行编码。 I've used Pip to import numpy but I'm getting an error when I add "import numpy" to my script: ModuleNotFoundError: No module named 'numpy'我已经使用 Pip 导入 numpy 但是当我将“import numpy”添加到我的脚本时出现错误:ModuleNotFoundError: No module named 'numpy'

It looks like Pip downloaded it okay, and put it into the folder: C:\Users\Alastair Heptonstall\AppData\Local\Programs\Python\Python39\Lib\site-packages\numpy貌似Pip下载好了,放到文件夹:C:\Users\Alastair Heptonstall\AppData\Local\Programs\Python\Python39\Lib\site-packages\numpy

PyCharm appears to be using the correct version of python (it has Python 3.9 in the lower right corner of the screen). PyCharm 似乎正在使用正确版本的 python(它在屏幕的右下角有 Python 3.9)。 And it looks like the version of Pip I used is the one that came with Python 3.9.看起来我使用的 Pip 版本是 Python 3.9 附带的版本。

Is this error caused by a path not being set correctly?此错误是由于路径设置不正确引起的吗?

Thanks for any help, very much appreciated!感谢您的帮助,非常感谢!

You can try this你可以试试这个

1. Open PyCharm . 1.打开PyCharm

2. go to File -> settings -> Project:untitled1 (untitled1 means your project name) -> select project interpretor -> click add button 2. go 到File -> settings -> Project:untitled1 (untitled1 means your project name) -> select project interpretor -> click add button

在此处输入图像描述

3. after clicking add button and search <package name> then install it. 3.点击添加按钮并搜索<package name>然后安装它。

finally, run the program.最后,运行程序。


Newer versions of Pycharm have a " + " mark (add button) here.较新版本的 Pycharm 此处有一个“ + ”标记(添加按钮)。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM