How to use PyPy on a Mac?

13,646

Have you tried using homebrew (http://brew.sh/)?

~ $ brew search pypy
pypy

Looks like a "brew install pypy" should get you there.

~ $ brew versions pypy
Warning: brew-versions is unsupported and may be removed soon.
Please use the homebrew-versions tap instead:
https://github.com/Homebrew/homebrew-versions
2.2.0    git checkout 4d471b1 /usr/local/Library/Formula/pypy.rb
2.1.0    git checkout ff5dd19 /usr/local/Library/Formula/pypy.rb
2.0.2    git checkout 58b36e9 /usr/local/Library/Formula/pypy.rb
2.0.1    git checkout 82b72d3 /usr/local/Library/Formula/pypy.rb
2.0      git checkout 280581d /usr/local/Library/Formula/pypy.rb
1.9      git checkout 28557b8 /usr/local/Library/Formula/pypy.rb
1.8      git checkout 93bda7d /usr/local/Library/Formula/pypy.rb
1.7      git checkout eee60ad /usr/local/Library/Formula/pypy.rb
1.6.0    git checkout b9b1f35 /usr/local/Library/Formula/pypy.rb
1.5.0    git checkout d0c75a9 /usr/local/Library/Formula/pypy.rb
1.4.1    git checkout 46c553a /usr/local/Library/Formula/pypy.rb
1.4      git checkout 61dd587 /usr/local/Library/Formula/pypy.rb
1.3      git checkout a546a1f /usr/local/Library/Formula/pypy.rb
1.2      git checkout 89de8bb /usr/local/Library/Formula/pypy.rb

edit: Alternatively have you checked whether or not you've put your install on your path? For instance, I grabbed it and put it into my home directory.

~ $ ll ~/ | grep pypy
drwxr-xr-x@  9 squiddly  staff    306 Nov 27 07:42 pypy-2.2.1-osx64

Then in my .bash_profile I put the following line in:

# Put pypy on my path
PATH=$PATH:$HOME/pypy-2.2.1-osx64/bin
export PATH

Now I can run pypy ~/scripts/test.py from wherever I want.

---- edit 2 ---- To answer the last question regarding the packages being missing:

"If you want to install 3rd party libraries, the most convenient way is to install distribute and pip:"

$ curl -O http://python-distribute.org/distribute_setup.py
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ ./pypy-2.1/bin/pypy distribute_setup.py
$ ./pypy-2.1/bin/pypy get-pip.py
$ ./pypy-2.1/bin/pip install pygments  # for example

"3rd party libraries will be installed in pypy-2.1/site-packages, and the scripts in pypy-2.1/bin"

-- from here: http://doc.pypy.org/en/latest/getting-started.html#installing-pypy

Share:
13,646

Related videos on Youtube

Lucien S.
Author by

Lucien S.

Updated on June 13, 2022

Comments

  • Lucien S.
    Lucien S. almost 2 years

    PyPy's speed promises make me want to try it. Unfortunately, none of the tutorials I read on the subject really helped me to understand the very basics, namely how to (in simple steps):

    • Install PyPy on Mac
    • Run a .py script

    I read that downloading, extracting and running pypy myscript.py from bin/ should do the trick, but no luck for me so far. Here's what I get:

    MyMacbook:bin User$ pypy myscript.py
    -bash: pypy: command not found
    

    Could anyone help me understand PyPy's basic usage?

    • DSM
      DSM over 10 years
      Does ./pypy work? (In the bin directory, I mean.)
    • Lucien S.
      Lucien S. over 10 years
      "$ ./pypy my script.py" works! Now I realize some "import" don't work, should I re-install the said libraries for pypy specifically? If so, how? Getting to the extracted library folder and typing "$ ./pypy setup.py install" don't work
  • Lucien S.
    Lucien S. over 10 years
    the most recent version available through brew is older than the one offered on pypy's website ( pypy.org/download.html ), is it still OK to install through brew? Cheers!
  • John P
    John P over 10 years
    Sure. You won't get 2.2.1, but you could always make an update to the homebrew script to get the latest if you really needed it. If you can get by with 2.2.0 I'd go with that personally. There's something to be said for compiling it yourself, but there's something to be said for being able to get work done as well. Also, without seeing a better stack trace or knowing where you're attempting to install it (/opt vs /usr/local vs ~/) I can't comment on compiling from source.