pip安裝 MySQLDb 和 Django


wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
[root@localhost ~]#tar -xvf pip-1.5.4.tar.gz
[root@localhost pip-1.5.4]#python setup.py install 

1. pip使用詳解

1.1 pip安裝包

[root@localhost ~]# pip install Django  
[root@localhost ~]# pip install MySQL-python 

 

 1.2 pip查看已安裝的包

[root@localhost ~]# pip list
MySQL-python (1.2.5)            //MySQLDb 
pip (1.5.4)
redis (2.10.5)
setuptools (23.1.0)
wsgiref (0.1.2)

1.3 pip檢查哪些包需要更新

[root@localhost ~]# pip list --outdated
pip (Current: 1.5.4 Latest: 8.1.2)

1.4 pip升級包

[root@localhost ~]# pip install --upgrade redis
Requirement already up-to-date: redis in /usr/local/lib/python2.7/site-packages
Cleaning up...

1.5 pip卸載包

2. pip參數解釋

[root@localhost ~]# pip --help

Usage:   
  pip <command> [options]

Commands:
  install                     Install packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  zip                         DEPRECATED. Zip individual packages.
  unzip                       DEPRECATED. Unzip individual packages.
  bundle                      DEPRECATED. Create pybundles.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output.
  --log-file <path>           Path to a verbose non-appending log, that only logs failures. This log is active by default at
                              /root/.pip/pip.log.
  --log <path>                Path to a verbose appending log. This log is inactive by default.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
  --cert <path>               Path to alternate CA bundle.

 

 

[root@localhost lib.linux-x86_64-2.7]# python
Python 2.7.9 (default, Mar 20 2016, 17:45:53) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

解決:

ln -s /usr/local/mysql56/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

如果是64系統則:
ln -s /usr/local/mysql56/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18

  vi /etc/ld.so.conf    //加入libmysqlclient.so.18 所在的目錄:/usr/local/mysql56/lib/

  加入: /usr/lib/

  保存退出后執行/sbin/ldconfig生效



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM