程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python error: solution to modulenotfounderror

編輯:Python

Catalog

Preface :

Text :

1.pip install requests:

2.PyCharm Install the software package inside :

  Last :

Preface :

Everybody knows python Various packages need to be imported into the project ( The package here refers to java Medium ), In Mandarin, it means Module.

And what is Module Well , Generally speaking, it is a module , Of course, the meaning of the module can be found by Baidu search ,Python modular (Module), It's a Python file , With .py ending , Contains Python Object definition and Python sentence . and Mudule The advantages of , Like maintainability 、 Reuse 、 Efficiency and so on need not repeat , What I want to share today is that when importing an external template ModuleNotFoundError To solve the problem .

Take the simplest example , Climb Weibo hot search list . I believe many young friends are beginning to learn python The reptile had this little actual battle , One of the most commonly used module Namely requests. If you just paste a piece of code from the Internet into PyCharm This is the error report in the operation ModuleNotFoundError, You're here csdn Search for this keyword inside , There will be many solutions , among pip install requests Is the most common , But many people follow the process in the article , But it still hasn't solved the problem . And the reason is that pip install requests Just put this requests The template has been downloaded to Scripts Under this folder , Instead of importing into your project . The following is the main body of this article .

Text :1.pip install requests:

( It's just taking requests Template examples , For other undetected errors module The same applies .)

win+r open cmd, Enter into python Of Scripts Folder , If there is no instruction here, please refer to my ;

    If you can't find the folder location, you can find the file location through the three right buttons downloaded in the start menu :

Of course, it will first send you to the file location of the shortcut , At this time, you only need to right-click any of the three to open the file location

  Then you can copy Scripts Folder path , Here's another trick: click on this folder icon to directly Ctrl+c La , Is it very useful .

  Now go on cmd In terms of instructions , stay Scripts The input pip install requests( there requests It can be anything you want module)

When there is a Successfully installed It means that it has been downloaded , I have downloaded this because requests This template , So it will be like what is written in the first box .

2.PyCharm Install the software package inside :

This is actually a very important step , I am here csdn The first search above ModuleNotFoundError The only solution to this problem is pip install module name The of this step . Let's continue to talk about how to install this package :

Open Settings , find Python Interpreter, Click on the plus sign

  Enter the... You want to import module name , Then click the template you want in the search results , And then click install

  Wait a few seconds and the installation will be completed , What you need at this time module It's already in your project .

  Last :

Share the module In fact, the installation method of is to make up for a little deficiency that has not been investigated in some stereotyped articles ,“ Must want to serve the weak , The green phoenix must come .” I hope it can be of some help to the friends who read this article !

This is about Python newspaper :ModuleNotFoundError This is the end of the article on wrong solutions , More about Python ModuleNotFoundError Please search the previous articles of the software development network or continue to browse the relevant articles below. I hope you will support the software development network in the future !



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved