How can I install h5py with Portable Python v2.7?

2019-09-08 09:21发布

问题:

I am doing some Python 2.7 development work on multiple computers, on some of which I do not have rights to install software. Thus, I am using Portable Python. One of the packages I need to use is h5py; however, since Portable Python installs without modifying the registry, the h5py installer doesn't see it as a valid Python installation. Also, simply extracting the h5py source to a custom F:\py\include folder and adding F:\py\include to the PYTHONPATH environment variable doesn't work, as import h5py results in an ImportError: Cannot import name _errors exception.

How do I install h5py with Portable Python 2.7?

回答1:

  1. Install Python 2.7 onto a computer for which you have sufficient administrative rights.
  2. Install the appropriate version of h5py into this Python installation.
  3. Find the h5py subfolder within the Python install (typically .\Lib\site-packages\h5py) and copy it to the F:\py\include folder mentioned (make sure to add F:\py\include to PYTHONPATH). See my answer here for more details.
  4. Uninstall the 'official' version of Python, if desired.