How to install external libraries with Portable Python?

后端 未结 4 1047
遥遥无期
遥遥无期 2020-12-06 21:38

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

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 22:08

    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'
    

提交回复
热议问题