0

I have looked at similar errors and the fixes I tried have not removed this error (yet).

Package        Version
-------------- ---------
beautifulsoup4 4.9.2
certifi        2020.6.20
chardet        3.0.4
idna           2.10
lxml           4.5.2
pip            20.2.3
requests       2.24.0
setuptools     49.2.1
soupsieve      2.0.1
urllib3        1.25.10

There's my current installs which I got from the terminal in VS Code. So, from what I can see, it is all there.

When I run from inside VS Code (the play button top right) I get this error:

[local address of file], line 3, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Further information *edit

I did install requests this way from the VS Code Terminal window:

 python -m pip install requests

The output states:

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in c:\users\[user]\appdata\roaming\python\python38\site-packages (2.24.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (2.10)      
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (1.25.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\[user]\appdata\roaming\python\python38\site-packages (from requests) (2020.6.20)

Any ideas on fixing this or a set of routine troublecheckers? Thanks kindly

Paul Davis
  • 495
  • 4
  • 14
  • probably installed in different python installation than the one being currently used in vs code – buran Oct 02 '20 at 14:56
  • VSC Debugger propably makes own Virtual Enviroment, so globally installed stuff will not work. Try to install it via VSC Console. – Kamil Oct 02 '20 at 14:57
  • @buran - the terminal output suggests that VS Code has access to the module from this file though. I possibly don't quite have a grasp of VS Code yet, it's only my second day of ever using it :) – Paul Davis Oct 02 '20 at 14:58
  • @Kamil - as far as I know I did install it via VSC Console and I can see the output above, also from VSC Console. Hmmmm... though I am very new to this so I might be missing something here. – Paul Davis Oct 02 '20 at 15:00
  • Not an answer to the question, but try add `--user` to the pip install and see if it makes any difference – Peter Oct 02 '20 at 15:16
  • probably you have more than one version of python. try `python -V` to see which version is used when `requests` is installed. Check that it is the same as the current interpreter as shown in the lower-left corner of VSCode window – buran Oct 02 '20 at 15:16
  • @buran - it appears you are correct. I do have different versions. Thanks. I will check how to update that. – Paul Davis Oct 02 '20 at 15:20
  • @buran - haha... noob question. How do I change that? I have 3.8.6 installed on the PC and using 3.7.5 on VS Code. – Paul Davis Oct 02 '20 at 15:26
  • 1
    Ctrl+Shift+P and select the interprter. Or click on the interpreter in the lower-left corner. That is if you want to run the script via right-cick and "Rund this file in Terminal". You can always run it using python3.8 yourfile.py (assuming python3.8 is pointing to that version - I don't know what your setup is, Obviously python points to 3.7) – buran Oct 02 '20 at 15:29
  • also look at https://stackoverflow.com/questions/43313903/how-to-setup-visual-studio-code-to-find-python-3-interpreter-in-windows-10 – buran Oct 02 '20 at 15:31

1 Answers1

0

You need to select the python interpreter to be the same of your current environment.

do

which python
/your_path/bin/python

That will give you the path, make sure the Python interpreter on your left button (at VSC) matches the same path, if not make it match.

JCMejias1
  • 3
  • 2