Problem with python modules

Asked

Viewed 35 times

0

I’m trying to run a simple condition that consists of a requisition. Only every time I try to run it on my Ubuntu 20 it returns the following error

  File "autobump.py", line 1, in <module>
  import requests
  ImportError: No module named requests

Using Pip list it returns that it is installed

inserir a descrição da imagem aqui

import requests
import time

while 1:
payload = {
    'content': '!d bump'
}

header = {
    'authorization': '*'
}

r = requests.post("https://discord.com/api/v9/channels/814170765690929162/messages", data=payload, headers=header)

print('bumped')
time.sleep(7260)

1 answer

0

This confusion is common when we have installed more than one version of python or use a virtualenv to package libraries needed for a particular project. If you have more than one version of python, then it means that you have a different set of libraries for each of these versions.

Now let’s go to one of the possible causes:

Depending on the IDE that you are using, it may have settings to indicate which interpreter (binary version of python) you want to use, as is the case of pycharm that I use.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

In this tab it is possible to see the interpreters that the IDE recognized by default or I added. With this I suggest you check whether the IDE points to the correct interpreter (which has the library requests and be the version of python that you want to use). If the interpreter you want to use is not showing up, then you need to add by the button add interpreter.

I also recommend that you pass more information regarding the environment you are using, if you are running the program directly by a button of IDE, if you actually owned more than one version of python, or if you are using virtualenv. If you can pass on this kind of information, it will make it easier for us to help you solve the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.