I can not import any Python module

0

I want to import the requests module from Python into a program I am doing, but it does not stop giving the following error, as soon as I run the program:

ModuleNotFoundError: No module named 'requests'

I have the latest version of Python installed (I reinstalled directly from the official website yesterday) and already logged in with the sudo pip install requests command in my MacOS Terminal to install the module. The module is already installed .

I do not know if I might need to put the module folder in the same folder as my program ... I do not know where to find the module folder anyway.

I'm new, so I'm sorry for ignorance.

Follow the code for my program.

import requests

#meu programa 

And my program (the .py file) is located directly on the Desktop of my Mac.

Where is my error?

Thank you!

    
asked by anonymous 02.08.2017 / 18:12

2 answers

1

Saints, I went through a similar difficulty a while ago, because I have several distinct Python versions installed on my Mac.

I solved the problem in a particular script as follows:

Observação: verifique se possui o módulo instalado com o comando: $ pip list (python2) $ pip3 list (python3+)

If it does not appear in pip list , possibly not installed, then give the command: pip install <nomeModulo> and make sure the module is installed on your machine.

1. I gave a which python3, to check where the main folder of my python3 is located

$ which python3

It returned me something like:

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

2. So I declare the path of the interpreter in my Python script

#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

PS: Above # -*- coding: utf-8 -*-

And my problem has been solved.

    
26.12.2018 / 14:33
0

Talk to Santos! Man, this looks like pip should be installing on your old version of python. Do the following. Try to execute the command by passing the version, this way down:

pip3.6 install requests

I assume q is the version 3.6 that you have there. If not, change the number to the corresponding version.

    
27.01.2018 / 01:09