Mysql應用簡略教程(三)。本站提示廣大學習愛好者:(Mysql應用簡略教程(三))文章只能為提供參考,不一定能成為您想要的結果。以下是Mysql應用簡略教程(三)正文
在python中裝置非自帶python模塊,有三種方法:
1.easy_install
2.pip
3.下載緊縮包(.zip, .tar, .tar.gz)後解壓, 進入解緊縮的目次後履行python setup.py install敕令
本文重要針對pip裝置時能夠會碰著的一種情形,及處理方法:
假設我要裝置pylint模塊,該模塊非python自帶模塊,用import確定不克不及導入,須要額定裝置
>>> import pylint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pylint
【景象】
履行pip install <modulename>敕令,報錯以下:
D:\>pip install pylint --allow-external pylint
Downloading/unpacking pylint
Requirement already satisfied (use --upgrade to upgrade): six in c:\python27\lib\site-packages\six-1
.8.0-py2.7.egg (from pylint)
Downloading/unpacking astroid>=1.3.6 (from pylint)
Real name of requirement astroid is astroid
Could not find any downloads that satisfy the requirement astroid>=1.3.6 (from pylint)
Some insecure and unverifiable files were ignored (use --allow-unverified astroid to allow).
Cleaning up...
No distributions at all found for astroid>=1.3.6 (from pylint)
Storing debug log for failure in C:\Users\aaa\pip\pip.log
【剖析】
在Perl中裝置新模塊,普通可以用PPM圖形化對象,也能夠用CPAN來裝置,好比說: cpan>install Test::Class, 異常便利,不會碰著這類情形,這類情形重要是由於pip版本成績: pip最新的版本(1.5以上的版本), 出於平安的考
慮,pip不許可裝置非PyPI的URL,由於該裝置文件現實下去自pylint.org,因此招致下面的毛病!
NOTE:
1. 可以在官方changelog外面檢查更改的信息
2. 可以用pip --version來檢查pip的版本信息
C:\>pip --version
pip 1.5.6 from C:\Python27\lib\site-packages (python 2.7)
【方法】
針對下面的情形,既然這個成績是由於pip版本的緣由,可以改用pip低一點的版本
辦法一: 用pip 1.4版本,再履行pip install pylint敕令來裝置
辦法二: 履行敕令時,加上--allow-all-external, --allow-unverified及依附包版本(astroid==1.3.6)
pip install pylint --allow-all-external pylint astroid==1.3.6 --allow-unverified pylint
NOTE:
1. --allow-all-external # 許可一切內部地址的標簽,只要打上該標簽pip方可下載內部地址模塊
2. --allow-unverified # pip沒有方法校驗內部模塊的有用性,所以必需同時打上該標簽
3. astroid==1.3.6 # 依附包必需要添加上,並付與其版本號,pip方能從列表下載
辦法三: 在以後目次下,新增requirements.txt,內容以下:
# requirements.txt
--allow-all-external pylint
--allow-unverified pylint
pylint
--allow-all-external astroid==1.3.6
再履行: pip install -r requirements.txt
【結論】
1. pip這個設計不敷友愛,應用也很不便利,遠不如Perl中的PPM,等待Python中也有這麼個對象。
2. 假如碰著這類錯,招致不克不及裝置模塊的話: 直接下載緊縮包裝置好了。 >>>下載包地址<<<
3. 履行pip -h敕令檢查更新pip相干的贊助信息
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 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.