简体   繁体   中英

Python: how to import 32bit module for 64bit python

Due to the system limits, I can only use a 64bit version Python, though, some of the modules that I intend to use do not come with a 64bit version (eg httplib2). In this case, what am I supposed to do so as to leverage those 32bit functions?

在此输入图像描述

Thanks for the answer by j_mcnally. That works. Another approach that eventually works for me is to use the prefix parameter if there are multi-versions(eg 32/64) of python installed:

python setup.py install --prefix = "your python root directory"

Excuse my ignorance, but can't you compile them as 64 bit modules?

http://code.google.com/p/httplib2/

the source is there. I would image most modern ./configure scripts will detect your arch, and compile the appropriate extension.

the following seems to work for me:

ARCHFLAGS='-arch x86_64' python setup.py install

running install running bdist_egg running egg_info writing

python2/httplib2.egg-info/PKG-INFO writing top-level names to

python2/httplib2.egg-info/top_level.txt writing dependency_links to

python2/httplib2.egg-info/dependency_links.txt reading manifest file

'python2/httplib2.egg-info/SOURCES.txt' reading manifest template

'MANIFEST.in' writing manifest file

'python2/httplib2.egg-info/SOURCES.txt' installing library code to

build/bdist.macosx-10.8-x86_64/egg running install_lib running

build_py creating build creating build/lib creating build/lib/httplib2

copying python2/httplib2/ init .py -> build/lib/httplib2 copying

python2/httplib2/iri2uri.py -> build/lib/httplib2 copying

python2/httplib2/socks.py -> build/lib/httplib2 copying

python2/httplib2/cacerts.txt -> build/lib/httplib2 creating

build/bdist.macosx-10.8- x86_64 creating

build/bdist.macosx-10.8- x86_64 /egg creating

http://www.lfd.uci.edu/~gohlke/pythonlibs/

This guy has made a windows installer (see Base-12.9.15.win-amd64-py2.7.‌exe at the bottom) for many, many modules used in scientific python. Consider using it, if you're not comfortable compiling from source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM