Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
904 views
in Technique[技术] by (71.8m points)

numpy - How to install external libraries with Portable Python?

I can't install Python on my machine due to administrator privileges, but I did download/open Portable Python successfully. I am on a Windows 7 64-bit machine. How would I be able to use the external libraries from before, such as Numpy or Gmpy?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

easy_install is trying to install from source. gmpy and gmpy2 are C extensions and require the presence of a compatible C compiler and other libraries (GMP; and MPFR and MPC for gmpy2). Installing from source is frequently difficult on Windows. The installers include a precompiled version of the extension.

One option is to extract the compiled binary from the installer. 7-Zip is able to open the installer file and you can extract the binary. In a standard Python installation, the extracted binary just needs to be placed in the site-packages directory. If necessary, you can do the extraction on another system and copy the file.

You can also use the zipfile module to extract the compiled extension. Here is an example. You will need to modify the exact file locations to reflect your system.

>>> import zipfile
>>> f=zipfile.ZipFile('gmpy2-2.0.0.win-amd64-py3.3.exe','r')
>>> f.namelist()
['PLATLIB/gmpy2-2.0.0-py3.3.egg-info', 'PLATLIB/gmpy2.pyd']
>>> f.extract('PLATLIB/gmpy2.pyd')
'C:\Python33\PLATLIB\gmpy2.pyd'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...