Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use PyPy on Windows?

Tags:

python

pypy

I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to "import psyco," but I found that PyPy.exe acted like the Python command line instead.

I tried dragging my scripts into the PyPy.exe to run them, but it didn't seem to work at all. Attempting to use the "python" command within PyPy yielded a "global name 'python' is not defined."

So I was hoping if someone can assist me in making PyPy run because I'm pretty much out of ideas. The documentation on the PyPy website confused me mainly and was not very helpful.

Ans: I found that I could simply right-click the script and "Open with" Pypy.exe to make it work. Not sure why it didn't work with the drag since I thought that was equivalent. Thanks everyone.

like image 346
chrtan Avatar asked Mar 27 '12 16:03

chrtan


People also ask

How do you run a PyPy?

For Python 2.7, it's just called pypy . For CPython, if you would like to run Python 3 from the terminal, you simply enter the command python3 . To run PyPy, simply issue the command pypy3 .

How do I use PyPy code in Visual Studio?

VS Code offers a ready to use Python extension that enables you to work with Jupyter notebooks within VS Code. To install the extension, open your VSCode and open the extensions tab by pressing Ctrl + Shift + X. In the search bar type in “Python”, select the Python extension by Microsoft and install it.

Should I use PyPy or Python?

PyPy works best with pure Python applications. Whenever you use a C extension module, it runs much slower than in CPython. The reason is that PyPy can't optimize C extension modules since they're not fully supported. In addition, PyPy has to emulate reference counting for that part of the code, making it even slower.


2 Answers

I'm a noob and was totally confused as well so here's what I did in case it helps someone. I guess this is so basic that pypy doesn't mention it.

  1. Download the appropriate file based on your OS: http://pypy.org/download.html

  2. unzip/uncompress/unpack/extract to any directory eg: C:\

  3. navigate to the directory in windows explorer and copy the path, eg: C:\pypy-2.5.0-win32

  4. control panel>system>advanced system settings>environment variables

  5. in the first box, select PATH

  6. click edit

  7. You'll see a bunch of paths. Don't alter any of them. Move the cursor to the very end.

  8. type a semicolon: ;

  9. paste your path after the semicolon you just added to the end of the long list of paths eg: ;C:\pypy-2.5.0-win32

Note! The command will be the filename of the launcher name -.exe If your launcher is pypy3.exe, then the command will be pypy3.

If the filename is python.exe, then your command will be python and so on.

For pypy3 the default launcher is pypy3.exe

  1. close all the system setting boxes and exit shell if it's open

  2. open shell

  3. navigate to directory where your .py file is located

  4. type: pypy filename.py

Now you can run your code with pypy instead of python.

like image 91
MDE Avatar answered Oct 20 '22 18:10

MDE


Maybe I'm not following what you're trying to do, but isn't it just a question of opening a command prompt and running pypy myscriptname ? Assuming you've got all the paths for PyPy and your script straight, anyway (e.g. your script's in PyPy's folder).

like image 32
ChrisC Avatar answered Oct 20 '22 16:10

ChrisC