Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyPy: ImportError: No module named requests

Whenever I run

pypy test.py 

in the Mac OS X 10 Terminal, I get a

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

However, this works well and without any errors when I do

python test.py

and when I open up pip (and also pip3), it shows me that Requests2.9.1 was installed.

What could be a possibly causing the problem? I am happy about really any ideas or suggestions! Thank you very much in advance

like image 551
DaveTheAl Avatar asked Feb 27 '16 10:02

DaveTheAl


People also ask

How do you fix Importerror No module named requests?

Requests are not a built-in module (it doesn't come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it. If you are getting an error installing pip checkout pip: command not found to resolve the issue.

Does requests come with Python?

Requests is released under the Apache License 2.0. Requests is one of the most popular Python libraries that is not included with Python.


1 Answers

Like others alluded to, PyPy needs its own install of Pip.

Check if your PyPy install directory contains a pip executable in the /bin directory. If not, download get-pip and run it using PyPy. Then, you run this version of Pip and install requests. Then you're good to go!

like image 157
Christofer Ohlsson Avatar answered Sep 23 '22 06:09

Christofer Ohlsson