3

I know similar questions have been asked before but I couldn't find the solution to my problem.

I am getting the following error message after trying to import requests:

C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe C:/Users/Jm/PycharmProjects/Test/Test_001
Traceback (most recent call last):
  File "C:/Users/Jm/PycharmProjects/Test/Test_001", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

I only have one version of python installed and python -m pip install requests is saying all the requirements are already satisfied.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
VBAtesting
  • 33
  • 1
  • 4

2 Answers2

1

Run this code:

C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe -m pip install requests

This forces the installation directory to your python install.

This gives a much different effect than simply python -m pip install requests

Daniel Scott
  • 979
  • 7
  • 16
  • Accepted as answer. Small question though, how can I make sure every new python project can use this module without having to reinstall it every time? – VBAtesting Jan 08 '19 at 02:47
  • Good question: `C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe` is not your only installation of python. If you want this work reliably, you will need to path the \path\to\python for each install you use and do the same thing. – Daniel Scott Jan 08 '19 at 02:56
1

As @Daniel Scott mentioned before use the command mentioned above or below

$: path-to-your-python-command -m pip install name-of-module

If you are using linux/mac then you can find path-to-your-python command using:

$: which python3

/usr/bin/python3

Lets say your python is installed here /usr/bin/python3 and the module you are installing is requests. Then you can use:

$: /usr/bin/python3 -m pip install requests

Bimal
  • 865
  • 10
  • 18