0

I have Portable Python 3.2 on a USB drive as I am often writing programs on many different computers. I wish to install GMPY for the Portable Python however when I go on the website to download GMPY the versions I find are for direct computer install and not a manual install on the USB. I can not do this for all computers I work on as I do not have admin access for all of them. Could someone please guide me through installing GMPY on my USB? Thank you very much!

Hadi Khan
  • 577
  • 2
  • 8
  • 30

1 Answers1

1

The executable files that can be downloaded from PyPI (https://pypi.python.org/pypi/gmpy2) are just zip files in disguise. All you need to do is extract the gmpy2.pyd file and place it in the site-packages directory. See How to install external libraries with Portable Python? for more details.

Note: The following comments are specific to the Windows operating system.

Python extensions can be written in either Python, C, or a combination of both. The source code is usually distributed as a .tar.gz or .zip file. Extensions that use C are difficult to distribute as source code since most Windows systems lack a C compiler to compile the C code into a .pyd file.

To solve this issue, pre-compiled versions can be distributed as .exe files. These .exe files are really zip files with a small installer program. Unfortunately, the installer only works with the Python interpreters from www.python.org. A new "wheel" format (.whl) has been developed that doesn't include an installer but relies on an external Python Installation Program (aka pip) that extracts the files from a .whl file and copies them to site-packages.

For gmpy2, you can just extract the .pyd file and copy it to the site-packages directory.

For bitarray, you will need to download a pre-compiled file from here. bitarray uses a combination of Python and C and more than one file will need to be copied. Specifically, you will need to create a sub-directory called bitarray inside the site-packages directory and then copy _bitarray.pyd and __init__.py to site-packages\bitarray.

Community
  • 1
  • 1
casevh
  • 11,093
  • 1
  • 24
  • 35
  • Thank you! I tried to install bitarray this way as well but I could not find any .pyd file in the .tar.gz file I downloaded from PyPI. Any ideas as to how I would be able to install this? – Hadi Khan Apr 13 '15 at 07:39