windows和linux中搭建python集成开发环境IDE——如何设置多个python环境
2016-02-01 12:25
1061 查看
本系列分为两篇:
1、【转】windows和linux中搭建python集成开发环境IDE
2、【转】linux和windows下安装python集成开发环境及其python包
3、windows和linux中搭建python集成开发环境IDE——如何设置多个python环境
fromchris'sandbox
InthispostIwilldocumentmysetupofPython2.7.6inUbuntu14.04.Ofcourse,thebasePythonisinstalledbydefault,bothPython2.7.6andPython3.4.Trythefollowingintheterminal:
Asyoucansee,usingpythonpointstoPython2.7.6bydefault.However,python2andpython3canbeusedtoaccessthedesiredversion.IwillfocusoninstallingpackagesforPython2.7.6here.
UsingtheUbunturepository:
Or,fromagit/svnrepository:
Approach1hasmanyadvantagesforPythonusersthatdon’tneedtohavethelatestversionsofeverypackage.Inparticular,allofthepackagedependenciesincludingotherPythonpackages,linearalgebralibraries,etc.arealsoinstalledautomatically.Asaresult,ifyouarenewtoUbuntuandPython,strategy1isthewaytogo.
Iwilltakeadifferenttact,usingpiptoinstall,upgrade,andremovepackages.Also,IwillinstallallPythonpackagesasauser,thatis,nouseofsudo.ThismakesiteasytousethesameinstallprocedureonamachinewhereIdon’thavesudoprivileges–sayanUbuntucluster.However,Iwillneedsudotoinstallnon-Pythonlibraries,Fortrancompilers,etc.thatthePythonpackagesemploy.Onacluster,theSysAdminwouldhavetotodothispartformeandotherusers.
–startedit:2015,June1st–
RecentlyuseofpiponUbuntu14.04hasstartedtoissueawarningthatendswithInsecurePlatformWarning.Aftersomesearchingaround,I’vefoundthatthisisrelatedtoSSLandtheurllib3inPython2.7.6,theversiononUbuntu14.04–seehereifyouwantthedetails.Assuggestedinthediscussionlinkedabove,thiscanbefixedwiththefollowinginstalls(I’llusethe–userswitch,asintheexamplesbelow)
Withthatwe’resecuredandthewarningsgoaway.Ifyouarejuststartingout,tryinstallingpip,asbelow,andreturntothisinstallifuseofpipgivesyouwarnings.
–endedit:2015,June1st–
Ofcourse,thestartingpointistogetpipinstalled.Officialinstructionsarealsoavailableforinstallingpip.pipdependsonsetuptools,butwecaninstallbothusingtheget-pip.pyscript,asdescribedattheinstalllink.Tobeconcrete,Ididthefollowing:
Ifyoudon’thavecurlinstalled,thiscanberemediedusing:
Becausewehavechosenlocalinstallation,thepath~/.local/binhastobeaddedtoourpath.Todothat,addthefollowingtotheendofyour~/.bashrcfile:
Then,source~/.bashrc:
Trythefollowingtoseeifyougetsimilarresultsandtomakesurethebasicsetupisworking:
Ofcourse,yourusernameshouldbeinthepath,buttheoutputshouldlooksomethingliketheabove.
AnothermajortoolforPython2.7projectmanagementisvirtualenv.ThispackageallowstheusertocreatemanyvirtualPythonenvironments,withdifferentpackagesinstalled,andtoactivateanddeactivetheseenvironmentswhenevertheuserdesires.Thisisextremelyusefulfordeveloperswhowanttocreateaminimalenvironmentfortheirapplication.
Thevirtualenvinstallationissimplewithpip(again,I’mdoingauserinstallwithnosudo):
Totestitout,seeifyougetsomethinglikethefollowing:
Nowthatvirtualenvisinstalled,therewillbetwopathsforwardfortherestofthePythoninstalls:
Keepinstallingasauser–I’llusethisapproachforthereasonsdiscussedabove.
Ifyouhaveadminpermissionsyoucaninstallallpackagesgloballyusingacommandlike:
CreateavirtualenvironmentandinstalleverythingtheretohaveacompletelyisolatedPythonenvironment–seevirtualenvandvirtualenvwrapperonUbuntu14.04foranexampleofhowtotakethisapproach.
Generaldevelopment/build:
Compilers/codeintegration:
Numerical/algebrapackages:
Fonts(formatplotlib)
Morefonts(formatplotlibonUbuntuServer14.04–seecommentatendofpost)–added2015/03/06
Graphvizforpygraphviz,networkx,etc.
IPythonrequirepandocfordocumentconversions,printing,etc.
Tinkererdependencies
That’sit,nowwestartinstallingthePythonpackages.
numpyisoneofthefundamentalnumericalpackagesinPython.Toinstallusingpiptype:
Thiswillresultinafairamountofcompilingfollowedbyanotethatthepackagewassuccessfullyinstalled.Ifnot,makeanoteoftheerror.Oftenthisresultsfromnothavinglibrariesand/orcompilersinstalled(seeabove).
Informationabouttheinstallationlocationandtheversioncanbeobtainedwiththefollowing:
Youshouldalsobeabletostartpythonattheterminalandimportnumpywithoutcomplaint:
scipyhasmanyusefulmathematicalutilities,complementingnumpy.Installationisaccomplishedwith:
Again,expectlotsofcompiling!Aswithnumpy,try:
and,loadingpython:
matplotlibisoneofthemainplottingpackagesforPythonandmanyotherpackagesusetheutilities.Installwith:
Ifyoulookcarefully,thecompletionoftheinstallationwillsay:
So,matplotlibinstallsavarietyofPython-dependencies.Asusual,try:
Finallytryasimpleplot:
Aplotshouldopeninanewwindowwhenplot.show()isexecuted.
sympyisacomputeralgebrasystemforPython.Installwithpipusing:
Again,installationinformationfrompipisobtainedwith:
Finally,followingthesympytutorial,startPythonandtry:
Cool!
Next,weinstallIPython(includingnotebooks),whichhasbecomeamajortoolforsharingpythonprojectsinaninteractiveformat.Toinstallweuse:
Attheend,wegetthemessage:
showingthatjinja2,pyzmqandmarkupsafehavealsobeeninstalled.Getinstallinformationfrompip:
Now,try:
whichlaunchestheIPythonterminal.NoticetheIPythonversionisprovidedandthepromptlooksdifferentfromthenormal>>>Pythonprompt(seetheIPythondocumentationformoreinformation):
Finally,IPythonnotebookcanbelaunchedwiththecommand:
ThislaunchesawebbrowserandyoushouldseetheIPythonnotebookinterface.Youcancreateanewnotebookandworkaway.Toshutdowntheserver,backattheterminalwhereyoulaunchedthenotebook,typecntrl-Candthenywhenprompted:
That’sit,you’renowanIPythonnotebookuser!
pygraphvizisaPythoninterfacetothegraphvizvisualizationcodethatcanbeusedbyitselfbutisalsoemployedbynetworkxandotherpackages.Besurethatgraphvizanditsdeveloperlibrariesareinstalled(seeUbuntuDependenciesabove)andinstallpygraphvizusing:
Getinstallinformationfrompip:
Also,try:
networkxisaPythonpackageforbuilding,analyzing,andvisualizinggraphs/networks.Thereareavarietyofdependencies,allofwhichwehaveinstalledabove.So,installwith:
Getinstallinformationfrompip:
Tryasimpleexample:
Withmatplotlibandpygraphvizinstalled(seeabove),thiscodeshouldcreateaverysimplegraphandshowitinanewwindowwhenplt.show()isexecuted.
pandasisaPythonpackagedfocusedondata–reading,writing,manipulating,etc.Thereareavarietyofpandasdependencies:required,recommendedandoptional.We’llfocusonthefirsttwocategories.
Therequireddependenciesarenumpy(installedabove),python-dateutil(installedabovewithmatplotlib),andpytz(wewillletpipinstallwithpandas).However,let’sinstalltherecommendeddependencies:
numexpr
Afterinstallweget:
bottleneck
Afterinstallweget:
WecanalsoimportbothpackagesinPythonandprintthepackageversiontomakesurethatbasicusageseemsokay:
Finally,forpandas,weinstallthemainpackage:
Aftersomedownloadingandcompilingweget(showingthatbothpandasandpytzwereinstalled,asexpected):
Usepiptochecktheinstallationinformation:
Note:ifyouimportpandas,anerroraboutopenpyxl(apackageforworkingwithExcel2007files)willbeissued:
Theerrorsaysthatopenpyxlneedstobeatleastversion1.6.1andlessthan2.0.0.Strange,thispackageislistedasoptional.Ohwell,let’sinstallanappropriateversion.Ifwejustusepiptoinstallthecurrentversionitwillbetoohigh.So,Iinstalledasfollows:
openpyxl1.8.6
Thisinstallforcestheuseanappropriateversion.Now,tryimportingpandasandweget:
Yay(!)wecanimportpandas(andopenpyxl)withoutcomplaints.
Finally,beforeleavingpandas,Iwillmentionthatthereareavarietyofoptionalpandasdependenciesthatyoumightwanttoconsideraswell.Iwon’tconsidertheminthispost.
pymcisareallyniceMCMCpackageforPython.Ihaveuseditonseveralprojectswithgreatsuccess.Installationwithpipfollowstheusualformat:
Getinstallinformation:
StartingPythonyoushouldalsobeabletoget:
statsmodelsprovidessomenicestatisticsmethods.Beforeinstallingstatsmodelsitself,wemustinstalldependencies,whichwilllikelybeusesulinanycase:patsyandcython.
patsy:isapackagefordescribingstatisticalmodelsinR-likeformat.Installwith:
Wecanseewherepipinstalledpatsy:
andtryimportingpatsyinaPythonsession:
cython:allowsforwrappingofc++code.Installwith:
Checkwithpip:
andimportinginaPythonsession:
Finally,installstatsmodelswithpip:
Showinstallinfowithpip:
andtryanimport:
Okay,that’spatsy,cythonandstatsmodels.
CMPyisapackageforComputationalMechanicsinPythondevelopedintheCrutchfieldLabatUCDavis.Currentlythepackageisdeveloped,usinggitforversioncontrol,butisnotpubliclyavailable.However,Iwilldocumenttheinstallherebecause:
It’susefulforpeopleatUCD(orcollaboratingwithpeopleatUCD)
ThisisanexampleofinstallationofaPythonpackageinafolderonthelocalmachine
IstartbyshowingthatIhaveclonedtheCMPypackagetothe~/gitlocal/cmpy/directory.Youcanseethesetup.pyfilewhenIshowthedirectorycontents:
Wedotheinstallwithpip,usingthe-eswitchtoshowthelocationofthepackagecode:
NotethatthepathtotheCMPydirectoryisaddedtoeasy-install.pth,afilethatPythonconsultstofindCMPy.Finally,weshowthepipinformation:
Again,notethatthelocationis~/gitlocal/cmpy/,insteadof~/.local/lib/python2.7/site-packages/,duetothe-etag.Thisiswhytheadditiontotheeasy_install.pthfile(above)wasneeded.
Edit:Aug21st,2014
Anoteonupdatingthislocalinstallationisinorder.Recentlyachangeincodewasmadethataffectedunderlyingccodethatisincorporatedusingcython.Ipulledtherepositorychangesusing:
TotryandupdatetheinstallIdid:
Thisranthesetup.pyfilebutdidnotrecompilethemodifiedccode.TogetthistoworkIhadtoremovethebuilddirectory,buildinplaceandinstallagain:
Isthereabetterwaytodothis?Letmeknowinthecommentsbelow.
restviewisaPythonpackagethatprocessesreStructuredTextandlaunchesawebbrowserforviewing.Eachtimethebrowserisrefreshed,theunderlyingrstdocumentwillbere-processedanddisplayed–veryniceforworkingonPythondocmentationoranyrstdocument.Installationgoesasusual:
Wecanseewhatwasinstalled:
Asyoucanseefromabove,docutilsandpygmentswillbeinstallediftheyarenotalreadyinstalled.
Toprocessanrstdocumentnamedtest.rsttype:
Checkrestviewformoreexamples.
tinkererisabloggingenvironmentforPythonistasthatisbuiltonSphinx,aPythondocumentationtool.BlogentriesarewritteninreStructuredTextandrenderedasstatichtml.Ofcourse,thisisalsothetoolIuseforthisblog.Beforemovingtoourusualpipinstall,wehavetotakecareofsomeUbuntu14.04Pythondependencies.Assumingtheserequirementsareavailable,tinkererisinstalledwiththeusual:
Wecanchecktheinstallinformationwith:
NotethatrequirementsJinja2,Sphinx,Babelandpyqueryarealsoinstalledautomatically.Aquickstarttogettingablogupandrunning(atleastthegenerationofposts,pagesandgeneratingthehtmloutput)isavailablehere.
PweaveisatoolforliterateprogrammingwithPython.ThistoolallowsmetowriteblogpostsaboutPythonusinga.PnwfilethatcontainsreStructuredText,alongwithspecialPweavecommands,andhavethePythoncodeevaluatedandoutputincludedinthe.rstoutputfile–seetheexamplehere.Thisisareallynicetooltoavoidtyposincodeandtomakesurethatwhatyou’retalkingaboutactuallyworks!IshouldnotethatIPythonnotebookscanalsodothisbyexportingtoreStructuredText.Inanycase,Iwilltryingoutbothofthesetoolsforfutureposts.
TheinstallofPweavegoesasusual:
Checktheinstallwith:
scikit-learnistheprobablythemostwell-knownandfeature-completepackageformachinelearningtasksinPython.Thereareanumberofdependenciesthatneedtobeinstalled(numpy,scipy,python-dev,etcseescikit-learninstallationformoreinformation)thathavealreadybeeninstalledabove.So,weinstallusingpip,asusual:
Thenwecanchecktheinstalledversionandlocationusing:
That’sit,machine-learnaway!
PostedbyChrisStrelioff
Tags:python2.7,ubuntu14.04,python,myubuntusetup,pip,virtualenv,numpy,scipy,matplotlib,sympy,ipython,pygraphviz,networkx,pandas,numexpr,bottleneck,openpyxl,pymc,statsmodels,patsy,cython,cmpy,restview,tinkerer,pweave,scikit-learn
«InstallingOctaveonUbuntu14.04
1、
2、
3、
InstallPythonpackagesonUbuntu14.04
fromInthispostIwilldocumentmysetupofPython2.7.6inUbuntu14.04.Ofcourse,thebasePythonisinstalledbydefault,bothPython2.7.6andPython3.4.Trythefollowingintheterminal:
$python--version Python2.7.6 $python2--version Python2.7.6 $python3--version Python3.4.0
Asyoucansee,usingpythonpointstoPython2.7.6bydefault.However,python2andpython3canbeusedtoaccessthedesiredversion.IwillfocusoninstallingpackagesforPython2.7.6here.
Strategy
InthepastIhaveinstalledPythonpackages:UsingtheUbunturepository:
$sudoapt-getinstallpackagename
Or,fromagit/svnrepository:
$sudopythonsetup.pyinstall
Approach1hasmanyadvantagesforPythonusersthatdon’tneedtohavethelatestversionsofeverypackage.Inparticular,allofthepackagedependenciesincludingotherPythonpackages,linearalgebralibraries,etc.arealsoinstalledautomatically.Asaresult,ifyouarenewtoUbuntuandPython,strategy1isthewaytogo.
Iwilltakeadifferenttact,using
–startedit:2015,June1st–
RecentlyuseofpiponUbuntu14.04hasstartedtoissueawarningthatendswithInsecurePlatformWarning.Aftersomesearchingaround,I’vefoundthatthisisrelatedtoSSLandtheurllib3inPython2.7.6,theversiononUbuntu14.04–
$pipinstall--userpyopensslndg-httpsclientpyasn1
Withthatwe’resecuredandthewarningsgoaway.Ifyouarejuststartingout,tryinstallingpip,asbelow,andreturntothisinstallifuseofpipgivesyouwarnings.
–endedit:2015,June1st–
pip
Ofcourse,thestartingpointistoget$cd~/Downloads $curl-Ohttps://bootstrap.pypa.io/get-pip.py$pythonget-pip.py--user
Ifyoudon’thavecurlinstalled,thiscanberemediedusing:
$sudoapt-getinstallcurl
Becausewehavechosenlocalinstallation,thepath~/.local/binhastobeaddedtoourpath.Todothat,addthefollowingtotheendofyour~/.bashrcfile:
#include.local/binforlocalpythonscripts exportPATH=~/.local/bin:$PATH
Then,source~/.bashrc:
$source~/.bashrc
Trythefollowingtoseeifyougetsimilarresultsandtomakesurethebasicsetupisworking:
$whichpip /home/cstrelioff/.local/bin/pip $pip--version pip1.5.6from/home/cstrelioff/.local/lib/python2.7/site-packages(python2.7)
Ofcourse,yourusernameshouldbeinthepath,buttheoutputshouldlooksomethingliketheabove.
virtualenv
AnothermajortoolforPython2.7projectmanagementisThe
$pipinstall--uservirtualenv
Totestitout,seeifyougetsomethinglikethefollowing:
$virtualenv--version 1.11.6 $pipshowvirtualenv --- Name:virtualenv Version:1.11.6 Location:/home/cstrelioff/.local/lib/python2.7/site-packages Requires:
Nowthat
Keepinstallingasauser–I’llusethisapproachforthereasonsdiscussedabove.
Ifyouhaveadminpermissionsyoucaninstallallpackagesgloballyusingacommandlike:
$sudopipinstallpackagename
CreateavirtualenvironmentandinstalleverythingtheretohaveacompletelyisolatedPythonenvironment–see
Ubuntudependencies
AvarietyofUbuntu-specificpackagesareneededbyPythonpackages.Thesearelibraries,compilers,fonts,etc.I’lldetailtheseherealongwithinstallcommands.Dependingonwhatyouwanttoinstallyoumightnotneedallofthese.Generaldevelopment/build:
$sudoapt-getinstallbuild-essentialpython-dev
Compilers/codeintegration:
$sudoapt-getinstallgfortran $sudoapt-getinstallswig
Numerical/algebrapackages:
$sudoapt-getinstalllibatlas-dev $sudoapt-getinstallliblapack-dev
Fonts(formatplotlib)
$sudoapt-getinstalllibfreetype6libfreetype6-dev
Morefonts(formatplotlibonUbuntuServer14.04–seecommentatendofpost)–added2015/03/06
$sudoapt-getinstalllibxft-dev
Graphvizforpygraphviz,networkx,etc.
$sudoapt-getinstallgraphvizlibgraphviz-dev
IPythonrequirepandocfordocumentconversions,printing,etc.
$sudoapt-getinstallpandoc
Tinkererdependencies
$sudoapt-getinstalllibxml2-devlibxslt-devzlib1g-dev
That’sit,nowwestartinstallingthePythonpackages.
numpy
$pipinstall--usernumpy
Thiswillresultinafairamountofcompilingfollowedbyanotethatthepackagewassuccessfullyinstalled.Ifnot,makeanoteoftheerror.Oftenthisresultsfromnothavinglibrariesand/orcompilersinstalled(seeabove).
Informationabouttheinstallationlocationandtheversioncanbeobtainedwiththefollowing:
$pipshownumpy --- Name:numpy Version:1.8.1 Location:/home/cstrelioff/.local/lib/python2.7/site-packages Requires:
Youshouldalsobeabletostartpythonattheterminalandimportnumpywithoutcomplaint:
Python2.7.6(default,Mar222014,22:59:56) [GCC4.8.2]onlinux2 Type"help","copyright","credits"or"license"formoreinformation. >>>importnumpyasnp >>>printnp.__version__ 1.8.1 >>>exit()
scipy
$pipinstall--userscipy
Again,expectlotsofcompiling!Aswith
$pipshowscipy --- Name:scipy Version:0.14.0 Location:/home/cstrelioff/.local/lib/python2.7/site-packages Requires:
and,loadingpython:
Python2.7.6(default,Mar222014,22:59:56) [GCC4.8.2]onlinux2 Type"help","copyright","credits"or"license"formoreinformation. >>>importscipy >>>printscipy.__version__ 0.14.0 >>>exit()
matplotlib
$pipinstall--usermatplotlib matplotlib复杂一点,可能直接上面的操作会失败:需要先安装其依赖的包libpng和freetype,根据提示缺啥就补安装啥即可: 安装libpng:sudoapt-getinstalllibpng-dev 安装freetype: cd~/Downloads wgethttp://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz tarzxvffreetype-2.4.10.tar.gz cdfreetype-2.4.10/ ./congfigure make sudomakeinstall
Ifyoulookcarefully,thecompletionoftheinstallationwillsay:
Successfullyinstalledmatplotlibpython-dateutiltornadopyparsingnose
backports.ssl-match-hostname
Cleaningup...
So,
$pipshowmatplotlib
---
Name:matplotlib
Version:1.3.1
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:numpy,python-dateutil,tornado,pyparsing,nose
Finallytryasimpleplot:
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importmatplotlib.pyplotasplt
>>>plt.plot([1,2,3,4])
[<matplotlib.lines.Line2Dobjectat0x7f13a8571890>]
>>>plt.ylabel('somenumbers')
<matplotlib.text.Textobjectat0x7f13a85c47d0>
>>>plt.show()
>>>exit()
Aplotshouldopeninanewwindowwhenplot.show()isexecuted.
sympy
$pipinstall--usersympy
Again,installationinformationfrom
$pipshowsympy
---
Name:sympy
Version:0.7.5
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
Finally,followingthe
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>fromsympyimportsymbols
>>>x,y=symbols('xy')
>>>expr=x+2*y
>>>expr
x+2*y
>>>expr+1
x+2*y+1
>>>expr-x
2*y
>>>exit()
Cool!
IPython
Next,weinstall$pipinstall--useripython[notebook]
Attheend,wegetthemessage:
Successfullyinstalledipythonjinja2pyzmqmarkupsafe
Cleaningup...
showingthatjinja2,pyzmqandmarkupsafehavealsobeeninstalled.Getinstallinformationfrom
$pipshowipython
---
Name:ipython
Version:2.1.0
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
Now,try:
$ipython
whichlaunchesthe
Python2.7.6(default,Mar222014,22:59:56)
Type"copyright","credits"or"license"formoreinformation.
IPython2.1.0--AnenhancedInteractivePython.
?->IntroductionandoverviewofIPython'sfeatures.
%quickref->Quickreference.
help->Python'sownhelpsystem.
object?->Detailsabout'object',use'object??'forextradetails.
In[1]:importnumpyasnp
In[2]:printnp.__version__
1.8.1
In[3]:exit()
Finally,
$ipythonnotebook
Thislaunchesawebbrowserandyoushouldseethe
Shutdownthisnotebookserver(y/[n])?y
2014-06-0416:29:04.033[NotebookApp]CRITICAL|Shutdownconfirmed
2014-06-0416:29:04.033[NotebookApp]Shuttingdownkernels
That’sit,you’renowan
pygraphviz
$pipinstall--userpygraphviz
Getinstallinformationfrom
$pipshowpygraphviz
---
Name:pygraphviz
Version:1.2
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
Also,try:
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpygraphviz
>>>printpygraphviz.__version__
1.2
>>>exit()
networkx
$pipinstall--usernetworkx
Getinstallinformationfrom
$pipshownetworkx
---
Name:networkx
Version:1.8.1
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
Tryasimpleexample:
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importnetworkxasnx
>>>G=nx.Graph()
>>>G.add_edge(1,2)
>>>G.add_edge(2,3)
>>>importmatplotlib.pyplotasplt
>>>nx.draw(G)
>>>plt.show()
>>>exit()
With
pandas
Therequireddependenciesare
$pipinstall--usernumexpr
Afterinstallweget:
$pipshownumexpr
---
Name:numexpr
Version:2.4
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:numpy
$pipinstall--userBottleneck
Afterinstallweget:
$pipshowBottleneck
---
Name:Bottleneck
Version:0.8.0
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
WecanalsoimportbothpackagesinPythonandprintthepackageversiontomakesurethatbasicusageseemsokay:
$python-c"importnumexpr;printnumexpr.__version__"
2.4
$python-c"importbottleneck;printbottleneck.__version__"
0.8.0
Finally,for
$pipinstall--userpandas
Aftersomedownloadingandcompilingweget(showingthatbothpandasandpytzwereinstalled,asexpected):
Successfullyinstalledpandaspytz
Cleaningup...
Use
$pipshowpandas
---
Name:pandas
Version:0.14.0
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:python-dateutil,pytz,numpy
Note:ifyouimport
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpandas
/home/cstrelioff/.local/lib/python2.7/site-packages/pandas/io/excel.py:626:UserWarning:Installedopenpyxlisnotsupportedatthistime.Use>=1.6.1and<2.0.0.
.format(openpyxl_compat.start_ver,openpyxl_compat.stop_ver))
>>>exit()
Theerrorsaysthatopenpyxlneedstobeatleastversion1.6.1andlessthan2.0.0.Strange,thispackageislistedasoptional.Ohwell,let’sinstallanappropriateversion.Ifwejustuse
openpyxl1.8.6
$pipinstall--useropenpyxl==1.8.6
Thisinstallforcestheuseanappropriateversion.Now,tryimporting
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpandas
>>>printpandas.__version__
0.14.0
>>>importopenpyxl
>>>printopenpyxl.__version__
1.8.6
>>>exit()
Yay(!)wecanimport
Finally,beforeleaving
pymc
$pipinstall--userpymc
Getinstallinformation:
$pipshowpymc
---
Name:pymc
Version:2.3.2
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
StartingPythonyoushouldalsobeabletoget:
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpymc
>>>printpymc.__version__
2.3.2
>>>exit()
statsmodels
$pipinstall--userpatsy
Wecanseewhere
$pipshowpatsy
---
Name:patsy
Version:0.2.1
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:numpy
andtryimporting
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importpatsy
>>>printpatsy.__version__
0.2.1
>>>exit()
$pipinstall--userCython
Checkwith
$pipshowCython
---
Name:Cython
Version:0.20.1
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
andimportinginaPythonsession:
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importcython
>>>printcython.__version__
0.20.1
>>>exit()
Finally,install
$pipinstall--userstatsmodels
Showinstallinfowith
$pipshowstatsmodels
---
Name:statsmodels
Version:0.5.0
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
andtryanimport:
Python2.7.6(default,Mar222014,22:59:56)
[GCC4.8.2]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importstatsmodels
>>>printstatsmodels.__version__
0.5.0
>>>exit()
Okay,that’s
CMPy
It’susefulforpeopleatUCD(orcollaboratingwithpeopleatUCD)
ThisisanexampleofinstallationofaPythonpackageinafolderonthelocalmachine
IstartbyshowingthatIhaveclonedthe
$ls~/gitlocal/cmpy/
appsbuildCHANGES.txtcmpydatadocsgalleryLICENSE.txtMANIFEST.inold_docpylintrcREADME.txtscriptssetup.pysrc
Wedotheinstallwith
$pipinstall--user-e~/gitlocal/cmpy/
Obtainingfile:///home/cstrelioff/gitlocal/cmpy
Runningsetup.py(path:/home/cstrelioff/gitlocal/cmpy/setup.py)egg_infoforpackagefromfile:///home/cstrelioff/gitlocal/cmpy
Installingcollectedpackages:CMPy
Runningsetup.pydevelopforCMPy
Creating/home/cstrelioff/.local/lib/python2.7/site-packages/CMPy.egg-link(linkto.)
AddingCMPy1.0devtoeasy-install.pthfile
Installed/home/cstrelioff/gitlocal/cmpy
SuccessfullyinstalledCMPy
Cleaningup...
Notethatthepathtothe
$pipshowcmpy
---
Name:CMPy
Version:1.0dev
Location:/home/cstrelioff/gitlocal/cmpy
Requires:
Again,notethatthelocationis~/gitlocal/cmpy/,insteadof~/.local/lib/python2.7/site-packages/,duetothe-etag.Thisiswhytheadditiontotheeasy_install.pthfile(above)wasneeded.
Edit:Aug21st,2014
Anoteonupdatingthislocalinstallationisinorder.Recentlyachangeincodewasmadethataffectedunderlyingccodethatisincorporatedusingcython.Ipulledtherepositorychangesusing:
$cd~/gitlocal/cmpy/
$gitpull
TotryandupdatetheinstallIdid:
$pipinstall--user-e~/gitlocal/cmpy/
Thisranthesetup.pyfilebutdidnotrecompilethemodifiedccode.TogetthistoworkIhadtoremovethebuilddirectory,buildinplaceandinstallagain:
$cd~/gitlocal/cmpy/
$rm-rbuild/
$pythonsetup.pybuild_ext-i--cython
$pipinstall--user-e~/gitlocal/cmpy/
Isthereabetterwaytodothis?Letmeknowinthecommentsbelow.
restview
$pipinstall--userrestview
Wecanseewhatwasinstalled:
$pipshowrestview
---
Name:restview
Version:2.0.5
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:docutils,pygments
Asyoucanseefromabove,docutilsandpygmentswillbeinstallediftheyarenotalreadyinstalled.
Toprocessanrstdocumentnamedtest.rsttype:
$restviewtest.rst
Check
tinkerer
$pipinstall--usertinkerer
Wecanchecktheinstallinformationwith:
$pipshowtinkerer
---
Name:Tinkerer
Version:1.4.2
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:Jinja2,Sphinx,Babel,pyquery
Notethatrequirements
Pweave
Theinstallof
$pipinstall--userPweave
Checktheinstallwith:
$pipshowPweave
---
Name:Pweave
Version:0.21.2
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
scikit-learn
$pipinstall--userscikit-learn
Thenwecanchecktheinstalledversionandlocationusing:
$pipshowscikit-learn
---
Name:scikit-learn
Version:0.15.1
Location:/home/cstrelioff/.local/lib/python2.7/site-packages
Requires:
That’sit,machine-learnaway!
PostedbyChrisStrelioff
Tags:
«
相关文章推荐
- Putty 使用密钥远程登录到linux
- Linux 双网卡双网段,基于源IP的策略路由。
- iOS 即时通讯xmpp 之Linux搭建ejabberd服务器
- 详解Linux中hdparm命令查看硬盘信息的用法
- linux命令学习记录
- linux内核基础(系统调用,简明)
- VM虚拟机下CentOS 6.5配置IP地址的三种方法
- linux利用grep查看打印匹配的下几行或前后几行的命令
- 在Linux中使用pushd和popd命令操作目录的用法
- Tmux -- linux终端复用器
- dubbo 的monitor监控中心 配置过程_linux
- Linux磁盘空间监控告警
- 将命令加入linux的环境变量
- 【转】linux下杀死进程(kill)的N种方法
- Linux的IO性能监控工具iostat详解
- Linux下chkconfig命令详解
- 【转】centos的软件安装方法rpm和yum
- 【转】linux的hostname(主机名)修改详解
- 解读Linux中pwd与dirs目录查看命令的使用
- 在Ubuntu上为Android增加硬件抽象层(HAL)模块访问Linux内核驱动程序