python管理工具easy_install与pip

刚开始同步系统的接触python和linux,在昊妹妹的指引下学习了使用python管理工具,希望能够通过不断熟练来学习

1.记录之前先复习以下linux下常用目录

./  表示当前目录

~/ 表示home目录

文件夹or文件前加 . 表示隐藏文件夹or文件,ls命令无法查看隐藏文件,需要带参数-a

2.python管理包

python管理工具比较常见的有esay_install和pip,pip好像普遍认为好一点,所以我们用pip,网上找到一段比较两者的

pip was originally written to improve on easy_install in the following ways

  • All packages are downloaded before installation. Partially-completed installation doesn’t occur as a result.
  • Care is taken to present useful output on the console.
  • The reasons for actions are kept track of. For instance, if a package is being installed, pip keeps track of why that package was required.
  • Error messages should be useful.
  • The code is relatively concise and cohesive, making it easier to use programmatically.
  • Packages don’t have to be installed as egg archives, they can be installed flat (while keeping the egg metadata).
  • Native support for other version control systems (Git, Mercurial and Bazaar)
  • Uninstallation of packages.
  • Simple to define fixed sets of requirements and reliably reproduce a set of packages.
sudo apt-get install python-pip  

安装好了pip则可以使用了,但是默认的pypi源在国内速度太慢,可以导入清华的pypi源,或者v2ex的源。然后修改or添加配置文件: ~/.pip/pip.conf

把内容变为:

[global]

index-url = http://pypi.v2ex.com/simple/

timeout = 6000

然后pip的常用命令

pip help

pip install [name]

pip install '[name[==version]]'

pip install -U [name]

pip uninstall [name]

pip freeze

pip search [keyword]

pip show [name]

3. 建立python虚拟环境

virtualenv可以用于提供纯净的python环境,相互独立、没有依赖关系,这可以解决库的版本、依赖和权限的问题。需要删除应用时可以直接将该环境和应用的文件夹删除即可。virtualenv可以理解为python环境的虚拟机。详细介绍请猛戳这儿

virtualenv的安装很简单,直接使用pip安装即可:

pip install virtualenv

进入目录,并建立虚拟环境:

cd pythonenv

virtualenv pythonenv

激活虚拟环境:

cd pythonenv

source bin/activate

cd ..

好了,已经进入了pythonenv的虚拟环境了,应该还会有(pythonenv)的标识。

4.从github上下载python开源包

 

windows

之前研究了在linux下安装python包,最近要用到matplotlib画图,在服务器上死活不出结果,结果被龙哥告知服务器上当然用不了图形界面呀,果断又在windows上使用了python。

先是安装python,添加环境变量。

接着安装easy_install,这个可以在 http://pypi.python.org/pypi/setuptools 中下载,再直接运行ez_setup.py 或python ez_setup.py。这篇文章写的不错 Windows 下 Python easy_install 的安装 

 

   

 

你可能感兴趣的:(easy_install)