python,django,pip一些查看版本,升級版本的命令

1、pip

一、pip下載安裝

1.1 pip下載

1python

# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificateredis

1.2 pip安裝

1數據庫

2django

3curl

# tar -xzvf pip-1.5.4.tar.gzui

# cd pip-1.5.4url

# python setup.py installspa

 

2. pip使用詳解

2.1 pip安裝包

1.net

2日誌

3

# pip install SomePackage

  [...]

  Successfully installed SomePackage

2.2 pip查看已安裝的包

1

2

3

4

5

6

7

# pip show --files SomePackage

  Name: SomePackage

  Version: 1.0

  Location: /my/env/lib/pythonx.x/site-packages

  Files:

   ../somepackage/__init__.py

   [...]

2.3 pip檢查哪些包須要更新

1

2

# pip list --outdated

  SomePackage (Current: 1.0 Latest: 2.0)

2.4 pip升級包

1

2

3

4

5

6

7

# pip install --upgrade SomePackage

  [...]

  Found existing installation: SomePackage 1.0

  Uninstalling SomePackage:

    Successfully uninstalled SomePackage

  Running setup.py install for SomePackage

  Successfully installed SomePackage

2.5 pip卸載包

1

2

3

4

5

$ pip uninstall SomePackage

  Uninstalling SomePackage:

    /my/env/lib/pythonx.x/site-packages/somepackage

  Proceed (y/n)? y

  Successfully uninstalled SomePackage

         

3. pip使用實例

3.1 安裝redis              

1

# pip install redis

3.2 卸載redis

1

2

3

4

5

6

# pip uninstall redis

Uninstalling redis:

  /usr/lib/python2.6/site-packages/redis-2.9.1-py2.6.egg-info

.....省略一些內容....

Proceed (y/n)? y

  Successfully uninstalled redis

3.3 查看待更新包

1

2

3

4

pip list --outdate

pygpgme (Current: 0.1 Latest: 0.3)

pycurl (Current: 7.19.0 Latest: 7.19.3.1)

iniparse (Current: 0.3.1 Latest: 0.4)

 

4. 常見錯誤

4.1 ImportError No module named setuptools
請參考《ImportError No module named setuptools解決

 

5. pip參數解釋

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

# pip --help

 

Usage:   

  pip <command> [options]

 

Commands:

  install                     安裝包.

  uninstall                   卸載包.

  freeze                      按着必定格式輸出已安裝包列表

  list                        列出已安裝包.

  show                        顯示包詳細信息.

  search                      搜索包,相似yum裏的search.

  wheel                       Build wheels from your requirements.

  zip                         不推薦. Zip individual packages.

  unzip                       不推薦. Unzip individual packages.

  bundle                      不推薦. Create pybundles.

  help                        當前幫助.

 

General Options:

  -h, --help                  顯示幫助.

  -v, --verbose               更多的輸出,最多能夠使用3次

  -V, --version               現實版本信息而後退出.

  -q, --quiet                 最少的輸出.

  --log-file <path>           覆蓋的方式記錄verbose錯誤日誌,默認文件:/root/.pip/pip.log

  --log <path>                不覆蓋記錄verbose輸出的日誌.

  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.

  --timeout <sec>             鏈接超時時間 (默認15秒).

  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.

  --cert <path>               證書.

 

2、經常使用升級命令

1.把pip、django升級到最新

python -m pip install --upgrade
pip install --upgrade django

 

2.查看pip的版本

pip --version
pip -V

 

3.查看django版本

python
import django
django.VERSION

 

3、經常使用操做初始化數據庫,設置超管命令

1.初始化

python manage.py migrate
python manage.py makemigrations

2.設置超級管理員

python manage.py createsuperuser

3.初始化不成功時,啓用這個

python manage.py migrate --fake-initial

 

 

參考文檔:

1.https://blog.csdn.net/crisschan/article/details/53214439

相關文章
相關標籤/搜索