# Trouble importing 'requests' package: 2nd Video of Python Package Index Chapter: Complete Python Mastery Course

**URL:** <https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687>\
**Category:** Python\
**Created:** [July 14, 2022, 4:48pm UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687 "2022-07-14T16:48:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Achintya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/achintya/32/4152_2.png) [@Achintya](https://forum.codewithmosh.com/u/Achintya)\
**Post date:** [July 14, 2022, 4:48pm UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/1 "2022-07-14T16:48:37Z")

</div>

![Pip troubles](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/3/3f0e0dd0abb845ea3bb32685503df01c63478b2b.png)

As can be seen from the above screenshots, I’m having trouble importing the ‘requests’ package using Pip. I’ve verbatim followed the instructions pointed out in Mosh’s video titled Pip from the Python Package Index chapter. I can’t seem to figure out what could be going wrong.

Why does the terminal say: ModuleNotFoundError: No module named ‘requests’ ? Furthermore, pylint is saying: unable to import ‘requests’.

Any help would be greatly appreciated. Thanks a bunch!

---

<div class="post-metadata">

**Author:** ![JohnLu](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnLu](https://forum.codewithmosh.com/u/JohnLu)\
**Post date:** [July 15, 2022, 1:51am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/2 "2022-07-15T01:51:44Z")

</div>

Did you install the `requests` library on the system, for example, using the command line `pip install requests`?

Or maybe you’ve chosen the wrong environment, it looks like you run the script on `python 3.9.13 64-bit`, which is your system python interpreter, Maybe you have installed the library in a different virtual environment.

---

<div class="post-metadata">

**Author:** ![Achintya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/achintya/32/4152_2.png) [@Achintya](https://forum.codewithmosh.com/u/Achintya)\
**Post date:** [July 18, 2022, 11:33am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/3 "2022-07-18T11:33:07Z")

</div>

![piptroubles2](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/8/86f78e0484144edfa90f44d76c491e672ed809d5.png)

I went back to see where the requests package is installed and its path is shown in the picture above. I ran the command to install the requests package (pip install requests) from within the VS Code terminal. The only thing I can think of is the way my VS Code is configured, I think.

Also, I’m a little new to python and the terminal, so I didn’t fully understand what you meant by “choosing the wrong environment”. May you please clarify that? Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![JohnLu](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnLu](https://forum.codewithmosh.com/u/JohnLu)\
**Post date:** [July 18, 2022, 12:07pm UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/4 "2022-07-18T12:07:42Z")

</div>

From your screen capture, I recognized that you had installed the `requests` library in your virtual environment named `pyhton310`, correct?

But you didn’t choose the `Python310` environment like the left of the screen capture. check out the area I rectangle, click it, and select a proper environment; you’ll be ok.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/5/5c440d7400119673faec9a10915a78217b487144.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/c/c03951127f755d58d6edcd3834432d8c3f78f8dd.png)

---

<div class="post-metadata">

**Author:** ![Achintya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/achintya/32/4152_2.png) [@Achintya](https://forum.codewithmosh.com/u/Achintya)\
**Post date:** [July 20, 2022, 4:13am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/5 "2022-07-20T04:13:13Z")

</div>

![Inkedpiptroubles3](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/f/f23b1aff13fbd748723e1da296c4afdec21faf47.jpeg)

Thank you! That made progress! Now pylint recognizes the import but I still get the ModuleNotFoundError: no module named ‘requests’.

I went to double check where my requests package is stored. It is still in the python310 folder. What could be going wrong now? If the proper environment is selected and the import is recognized, why can the requests package/module not be found?

Thank you so much! 🙏

---

<div class="post-metadata">

**Author:** ![JohnLu](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnLu](https://forum.codewithmosh.com/u/JohnLu)\
**Post date:** [July 20, 2022, 5:47am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/6 "2022-07-20T05:47:19Z")

</div>

You still have the `ModuleNotFound` error because you have not executed the script via the right python environment.

Normally, when you open a new terminal in `vscode` it would automatically activate the virtual environment, in this case, `Python310`, but from your screen capture, you can see you still executed the script using the system python interpreter, not the one you think.

I made a small record for you to show how this works; perhaps this might be helpful.

![Video_2022-07-20_134314](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/2/24369c1c962bcc037decea9ed3a5c74b2bb9a135.gif)

---

<div class="post-metadata">

**Author:** ![Achintya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/achintya/32/4152_2.png) [@Achintya](https://forum.codewithmosh.com/u/Achintya)\
**Post date:** [July 20, 2022, 8:53am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/8 "2022-07-20T08:53:56Z")

</div>

![RunningDifferentTerminals](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/c/c33b9d217824bfa039497a9e6fa5c6511f6ccf27.jpeg)

Wow! It works! When I follow the gif you made, I finally get the output \<Response [200]\>. I’ll try to run all my python files this way. I was always running the terminal by opening it up in VS Code using the alt+shift+n keys. Why is there a difference between this function and opening it with the “run python file in terminal” command? Are there two different terminals I’m not aware of? Thanks!

---

<div class="post-metadata">

**Author:** ![JohnLu](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnLu](https://forum.codewithmosh.com/u/JohnLu)\
**Post date:** [July 20, 2022, 9:21am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/9 "2022-07-20T09:21:49Z")

</div>

I’m not so sure about the differences between the two ways. Maybe it has something to do with the types of the terminal; you see, the default type of terminal is `PowerShell.exe`， I have encountered a lot of problems for the first time using `VSCode`, So I changed to `cmd.exe` as terminal, and everything is fine. both the way I run the python script or yours worked.

Since it works just fine and worrying about causing some misunderstanding for English is not my native language, I didn’t dig deeper. Perhaps you can do some troubleshooting and if you figure it out, let me know, I would be very appreciated!

---

<div class="post-metadata">

**Author:** ![Achintya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/achintya/32/4152_2.png) [@Achintya](https://forum.codewithmosh.com/u/Achintya)\
**Post date:** [July 20, 2022, 1:08pm UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/10 "2022-07-20T13:08:40Z")

</div>

If using cmd.exe is better than using the default PowerShell.exe, would you recommend me to switch too? I feel that my will work only if I run the python file in the terminal, but I don’t see a way to open up the terminal without having to run the file.

I’m actually a complete newbie in programming so I wanted to ask a more seasoned expert like you if I can make the same switch you’ve made. What did you do to change your terminal to cmd.exe from the Powershell.exe.

I’m bringing this up because I am now encountering problems when trying to create a virtual environment with the ‘python -m venv env’ command.

---

<div class="post-metadata">

**Author:** ![JohnLu](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JohnLu](https://forum.codewithmosh.com/u/JohnLu)\
**Post date:** [July 21, 2022, 1:10am UTC](https://forum.codewithmosh.com/t/trouble-importing-requests-package-2nd-video-of-python-package-index-chapter-complete-python-mastery-course/13687/11 "2022-07-21T01:10:40Z")

</div>

About switching terminals, it’s really up to you. If you like `PowerShell.exe` , then use it; if don’t, switch it. That simple.

I’m not sure that I am qualified to provide professional tutorials. because, as I said, English is not my native language, and I am not good at it right now. some of my expressions have grammatical mistakes. So I’m most certainly sure that I may cause some misinterpretation if I offer you professional tutorials.

A little advice, Google is a powerful tool for you to learn programming, make good use of it. You can find answers in every situation and problem, at least when you are a newbie. And for virtual environment management, I recommend Anaconda; take a look at it; you will like it.
