6

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

DaveTheAl
  • 1,995
  • 4
  • 35
  • 65
  • 3
    You will also need to install that module for pypy, see e.g. http://stackoverflow.com/q/8510615/3001761. It's a completely different interpreter, it doesn't share modules with `python`. – jonrsharpe Feb 27 '16 at 10:18
  • @jonrsharpe This solve my problem. You should include this as an answer maybe, because I couldn't find the solution after hours of searching for a solution – DaveTheAl Feb 27 '16 at 17:36

2 Answers2

6

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!

Christofer Ohlsson
  • 3,097
  • 4
  • 39
  • 56
1

REF: https://towardsdatascience.com/run-your-python-code-as-fast-as-c-4ae49935a826

    STEP 1. Download https://www.pypy.org/download.html#
        Extract to:
            C:\Program Files\pypy\pypy3.7-v7.3.5-win64
    STEP 2. Set env variable %PATH%

    STEP 3. get pip
        https://doc.pypy.org/en/latest/install.html#installing-more-modules
        $ ./pypy-xxx/bin/pypy -m ensurepip
        $ ./pypy-xxx/bin/pypy -mpip install -U pip wheel # to upgrade to the latest versions
        $ ./pypy-xxx/bin/pypy -mpip install pygments  # for example

    STEP 4.
        pypy3 -mpip install -r requirements.txt

    STEP 5. 
       pypy3 .\src\entry\somescripts.py
user3761555
  • 851
  • 10
  • 21