Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
878 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 Reply

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'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...