如何创建python开发环境?

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

如何创建python开发环境?最近需要编译opencv-2.4.12,下载源码opencv-2.4.13.zip后,以下由浙江天搜整理分享:unzipopencv-2.4.13.zipcdopencv-2.4.12mkdirbuildcdbuildcmake..//报错,找不到ccmake..//GUI模式,进行相应的配置make在cmake配置时,CouldNOTfindPythonLibs(missing:PYTHON_INCLUDE_DIRSPYTHON_LIBRARIES),找不到PythonLibs,好吧,修改/usr/share/cmake/Modules/FindPythonLibs.cmake:因为我想用anaconda2,加入#fixedbyhouwenbin#set(PYTHON_FOUND1)#set(PYTHON_INCLUDE_DIRS/root/anaconda2/include)#set(PYTHON_LIBRARIES/root/anaconda2/lib)再次试,虽然找到了,仍然报:targetopencv_pythonrequestslinkingtodirectory......Targetsmaylinkonlytolibraries.CMakeisdroppingtheitem.表现为总是找到的是系统自带的Python2.6.6的so库。不想捣鼓系统的Python,那就还是用系统的吧!!!补全安装系统的Python开发环境:yuminstallpython-devel再次配置opencv,出现找不到numpy,安装,没有setuptools,安装:wget贴一下ez_setup.py#!/usr/bin/envpythonSetuptoolsbootstrappinginstaller.Maintainedat:fromurllib.requestimporturlopenfromurllib.parseimporturljoinexceptImportError:fromurllib2importurlopenfromurlparseimporturljointry:fromsiteimportUSER_SITEexceptImportError:USER_SITE=NoneLATEST=object()DEFAULT_VERSION=LATESTDEFAULT_URL==os.curdirdef_python_cmd(*args):Executeacommand.ReturnTrueifthecommandsucceeded.args=(sys.executable,)+argsreturnsubprocess.call(args)==0def_install(archive_filename,install_args=()):InstallSetuptools.witharchive_context(archive_filename):#installinglog.warn('InstallingSetuptools')ifnot_python_cmd('setup.py','install',*install_args):log.warn('Somethingwentwrongduringtheinstallation.')log.warn('Seetheerrormessageabove.')#exitcodewillbe2return2def_build_egg(egg,archive_filename,to_dir):BuildSetuptoolsegg.witharchive_context(archive_filename):#buildinganegglog.warn('BuildingaSetuptoolseggin%s',to_dir)_python_cmd('setup.py','-q','bdist_egg','--dist-dir',to_dir)#returningtheresultlog.warn(egg)ifnotos.path.exists(egg):raiseIOError('Couldnotbuildtheegg.')classContextualZipFile(zipfile.ZipFile):SupplementZipFileclasstosupportcontextmanagerforPython2.6.def__enter__(self):returnselfdef__exit__(self,type,value,traceback):self.close()def__new__(cls,*args,**kwargs):ConstructaZipFileorContextualZipFileasappropriate.ifhasattr(zipfile.ZipFile,'__exit__'):returnzipfile.ZipFile(*args,**kwargs)returnsuper(ContextualZipFile,cls).__new__(cls)@contextlib.contextmanagerdefarchive_context(filename):Unzipfilenametoatemporarydirectory,settothecwd.Theunzippedtargetiscleanedupafter.tmpdir=tempfile.mkdtemp()log.warn('Extractingin%s',tmpdir)old_wd=os.getcwd()try:os.chdir(tmpdir)withContextualZipFile(filename)asarchive:archive.extractall()#goinginthedirectorysubdir=os.path.join(tmpdir,os.listdir(tmpdir)[0])os.chdir(subdir)log.warn('Nowworkingin%s',subdir)yieldfinally:os.chdir(old_wd)shutil.rmtree(tmpdir)def_do_download(version,download_base,to_dir,download_delay):DownloadSetuptools.py_desig='py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)tp='setuptools-{version}-{py_desig}.egg'egg=os.path.join(to_dir,tp.format(**locals()))ifnotos.path.exists(egg):archive=download_setuptools(version,download_base,to_dir,download_delay)_build_egg(egg,archive,to_dir)sys.path.insert(0,egg)#Removepreviously-importedpkg_resourcesifpresent(see#).if'pkg_resources'insys.modules:_unload_pkg_resources()importsetuptoolssetuptools.bootstrap_install_from=eggdefuse_setuptools(version=DEFAULT_VERSION,download_base=DEFAULT_URL,to_dir=DEFAULT_SAVE_DIR,download_delay=15):Ensurethatasetuptoolsversionisinstalled.ReturnNone.RaiseSystemExitiftherequestedversionorlatercannotbeinstalled.version=_resolve_version(version)to_dir=os.path.abspath(to_dir)#priortoimporting,capturethemodulestatefor#representativemodules.rep_modules='pkg_resources','setuptools'imported=set(sys.modules).intersection(rep_modules)try:importpkg_resourcespkg_resources.require(setuptools=+version)#asuitableversionisalreadyinstalledreturnexceptImportError:#pkg_resourcesnotavailable;setuptoolsisnotinstalled;downloadpassexceptpkg_resources.DistributionNotFound:#noversionofsetuptoolswasfound;allowdownloadpassexceptpkg_resources.VersionConflictasVC_err:ifimported:_conflict_bail(VC_err,version)#otherwise,unloadpkg_resourcestoallowthedownloadedversionto#takeprecedence.delpkg_resources_unload_pkg_resources()return_do_download(version,download_base,to_dir,download_delay)def_conflict_bail(VC_err,version):Setuptoolswasimportedpriortoinvocation,soitisunsafetounloadit.Bailout.conflict_tmpl=textwrap.dedent(Therequiredversionofsetuptools(={version})isnotavailable,andcan'tbeinstalledwhilethisscriptisrunning.Pleaseinstallamorerecentversionfirst,using'easy_install-Usetuptools'.(Currentlyusing{VC_err.args[0]!r

1 / 14
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功