解決2:假設安裝whl相應版本號正確仍是報錯。則
This can also be caused by using an out-of-date pip with a recent wheel file.
Upgrading pip with python -m pip install --upgrade pip solved it.
http://blog.csdn.net/pipisorry/article/details/39902327php
直接安裝拓展包默認路徑:html
Unix(Linux)默認路徑:/usr/local/lib/pythonX.Y/site-packages查看pip安裝時相應的python版本號python
which piplinux
/d/python3.4.2/Scripts/pipc++
更新pip:git
python -m pip install --upgrade pip執行 python
github
而後import ×××,沒有提示錯誤就說明成功安裝sql
1. pip freeze | grep package_name數據庫
2. pip listdjango
dir(package_name)
help(package_name)
pip install --upgrade package_name
pip install -U PackageName
pip uninstall
windows分區下的文件夾權限爲root, root, sudo pip無效,但是權限是777應該是所有用戶都有讀寫權限的。
(ubuntu_env) pika:/media/pika/files/mine/$pip install pandas
Collecting pandas
Successfully built pandas
Installing collected packages: pandas
Exception:
PermissionError: [Errno 1] Operation not permitted
1 切換到root用戶。再pip安裝了(這以前要使root安裝python-pip),但是以前不用這麼作的,搞不懂哪裏出問題致使當前用戶不能pip安裝了。
2 使用sudo pip install
假設出錯:sudo pip command not found說明root用戶沒有安裝pip。且且當前使用的pip僅僅是當前用戶的。
解決:
sudo `which pip` install xxx
或者sudo `which pip` install xxx
sudo -E pip install xyz
遺憾的是。咱們需要引導pip正確地安裝知足需求的package. 因爲現在pip 還不具有真正的依賴分析, 僅僅是簡單地爲項目匹配第一需求。
Flask==0.10.1
numpy
Note: 不指定版本號則安裝最新版本號。也不要==符號。
pip install -r requirements.txt
sed -i 's/==.*$//g' requirements.txt 安裝最新版本號要去除後面的==再安裝
但有時你僅僅想將當前項目使用的類庫導出生成爲 requirements.txt;
使用pipreqs
pip的freeze命令僅僅保存與安裝在您的環境python所有軟件包。
$ pip install pipreqs
$ pipreqs /path/to/project
其餘選項詳見https://github.com/bndr/pipreqs
和Python(x,y)不同,在Ubuntu中需要手工安裝科學計算的各個模塊。
如下介紹怎樣在linux下安裝NumPy, SciPy, matplotlib, scikit-learn,NLTK,gensim,PIL,OpenCV,PyQt4, Spyder, Cython, SWIG, ETS
在Ubuntu下安裝Python模塊一般可以使用apt-get和pip命令
apt-get命令是Ubuntu自帶的包管理命令,而pip則是Python安裝擴展模塊的工具,一般pip會下載擴展模塊的源碼並編譯安裝。
1. Ubuntu 12.04中缺省安裝了Python2.7.3,首先經過命令sudo apt-get install python-pip安裝pip,pip是Python的一個安裝和管理擴展庫的工具。[Python的包管理工具]
2. Ubuntu 14.04中缺省安裝了Python2和Python3。經過命令sudo apt-get install python-pip安裝pip。經過命令sudo apt-get install python-pip3安裝pip3。
1. 經過apt-get命令高速安裝
sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo apt-get install python-matplotlib
可以在pycharm console中查看 numpy 版本號和路徑:
import numpy
print numpy.__version__
print numpy.__file__
2. 經過pip編譯安裝
》lz在virtualenv中經過pip3 install numpy安裝numpy成功!
》可以先用apt-get命令安裝所有編譯所需的庫:
sudo apt-get build-dep python-numpy
sudo apt-get build-dep python-scipy
而後經過pip命令安裝:
sudo pip install numpy
sudo pip install scipy
經過build-dep會安裝很是多庫。包括Python 3.2。
Note: scipy依賴numpy
PyQt4
如下的命令安裝PyQt4,Qt界面設計器,PyQt4的開發工具以及文檔:
sudo apt-get install python-qt4
sudo apt-get install qt4-designer
sudo apt-get install pyqt4-dev-tools
sudo apt-get install python-qt4-doc
cython和SWIG
Cython和SWIG是編寫Python擴展模塊的工具:
sudo pip install cython
sudo apt-get install swig
ETS
ETS是enthought公司開發的一套科學計算軟件包,當中的Mayavi經過VTK實現數據的三維可視化。
首先經過如下的命令安裝編譯ETS所需的庫:
sudo apt-get install python-dev libxtst-dev scons python-vtk pyqt4-dev-tools python2.7-wxgtk2.8 python-configobj
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
建立ets文件夾,並在此文件夾下下載ets.py。執行ets.py可以複製最新版的ETS源程序。並安裝:
mkdir ets
cd ets
wget https://github.com/enthought/ets/raw/master/ets.py
python ets.py clone
sudo python ets.py develop
#sudo python ets.py install 或者執行install安裝
假設一切正常。那麼輸入 mayavi2 命令則會啓動mayavi。
Building scikit-learn with pip
This is usually the fastest way to install or upgrade to the latest stablerelease:
pip install -U scikit-learn
pip install --user --install-option="--prefix=" -U scikit-learn
Note:1. The --user flag ask pip to install scikit-learn in the $HOME/.local folder therefore not requiring root permission. This flag should make pip ignore any old version of scikit-learn previously installed on the system while benefitting from system packages for numpy and scipy. Those dependencies can be long and complex to build correctly from source.
2. The --install-option="--prefix=" flag is only required if Python has adistutils.cfg configuration with a predefinedprefix= entry.
[http://www.nltk.org/install.html]
#pip install gensim
Note:gensim依賴NumPy和SciPy,要先安裝
[PyQt教程 - pythonQt的安裝和配置及版本號間差別]
查看版本號
pkg-config --modversion opencv
[opencv Installation in Linux]
python-opencv:
環境
ubuntu 12.04 LTS
python 2.7.3
opencv 2.3.1-7
安裝依賴
sudo apt-get install libopencv-*
sudo apt-get install python-opencv
sudo apt-get install python-numpy
【UBUNTU下安裝OPENCV和測試python-opencv】
【ubuntu 下 安裝 python-opencv 配置】
dpkg -L python-opencv命令查看,搜索安裝到何處
root@ubuntu:~#dpkg -L python-opencv測試opencv安裝好沒:
################################### # coding=utf-8 # !/usr/bin/env python # __author__ = 'pipi' # ctime 2014.10.12 # 測試opencv ################################### import cv if __name__ == '__main__': img = cv.LoadImageM ("faces.jpg") # 打開圖像 cv.NamedWindow ("ShowImage") # 建立窗體 cv.ShowImage ("ShowImage", img) # 顯示圖像 cv.WaitKey (0)python-opencv這個基本過期了,cv2是opencv本身帶的python綁定,編譯opencv應該就有了
python-opencv:
更新下載更新軟件包列表信息
apt-get update
查詢OpenCV相關軟件包
$ apt-cache search opencv
libcv-dev - development files for libcv
libcv1 - computer vision library
libcvaux-dev - development files for libcvaux
libcvaux1 - computer vision extension library
libhighgui-dev - development files for libhighgui
libhighgui1 - computer vision GUI library
opencv-doc - OpenCV documentation and examples
python-opencv - Python bindings for the computer vision library
//以上內容多是沒有及時更新
//用命令行$ apt-cache search opencv在ubuntu(12.04LTS)找到的最新的opencv版本號是2.1
harpia - Image Processing/Computer Vision Automatic Prgm. Tool
libcv-dev - development files for libcv
libcv2.1 - computer vision library
libcvaux-dev - development files for libcvaux
libcvaux2.1 - computer vision extension library
libhighgui-dev - development files for libhighgui
libhighgui2.1 - computer vision GUI library
opencv-doc - OpenCV documentation and examples
python-opencv - Python bindings for the computer vision library
在這裏,OpenCV的庫CxCore和Cv都被包括入Deb包libcv中。
安裝相關軟件包
假設僅僅是用來執行OpenCV程序。僅需安裝libcv1,libcvaux1。libhighgui1:
apt-get install libcv1 libcvaux1 libhighgui1
假設你要使用OpenCV來編敲代碼,那麼還需要安裝libcv-dev,libcvaux-dev,libhighgui-dev包。
apt-get install libcv-dev libcvaux-dev libhighgui-dev
文檔在opencv-doc包中,python-opencv是OpenCV的Python語言包。可依據需要安裝。
測試安裝包
測試是否成功安裝,你可以使用如下的命令行編譯位於源碼包中的drawing.c樣例:
g++ drawing.c `pkg-config opencv --libs --cflags opencv` -o drawing
成功編譯後你應該可以可以執行./drawing看到highgui輸出窗體的結果了.
c-opencv?
爲了編譯OpenCV需要下載cmake編譯工具。和一些依賴庫:
sudo python setup.py install
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install cmake-gui
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libjasper-dev
而後終端輸入http://sourceforge.net/projects/opencvlibrary/files/latest/download?source=files下載opencv源碼
或者從 http://sourceforge.net/projects/opencvlibrary/下載最新版的OpenCV源碼,並解壓。
而後建立編譯用的文件夾release,並啓動cmake-gui:
mkdir release
cmake-gui
在界面中選擇OpenCV源碼的文件夾,和編譯輸出文件夾release,而後按Configurebutton。並依據需要設置各個編譯選項,最後點Generatebutton。退出cmake-gui界面。進入編譯路徑。執行如下的命令:
cd release
make
sudo make install
安裝完成以後,啓動IPython,並輸入 import cv2 測試OpenCV可否正常加載。在Ubuntu下貌似OpenCv不兼容使用apt-get安裝numpy和scipy貌似,好像版本號太低。個人解決方法是下了最新的numpy和scipy,而後本身編譯安裝上去的。爲了安裝這兩個軟件,我又安裝了另一大堆東西。
ps:在Ubuntu下貌似OpenCv不兼容使用apt-get安裝numpy和scipy貌似,版本號太低。解決方法是下載最新的numpy和scipy。而後本身編譯安裝上去的。
爲了安裝這兩個軟件,還要安裝了另一大堆東西。
{開始以前,可以給系統作一下備份。
如誤安裝了Postgresql,出現了大問題就不得不把系統給重裝了}
因爲Ubuntu 12.10自帶 Postgresql 9.1, 就不用下載了,直接在terminal 裏輸入命令行就可以安裝。
命令行例如如下:
sudo apt-get install postgresql-9.1
而後安裝必要的包,附上官網的介紹及網址。有些包在以前可能已經被安裝過了,但是保險起見,仍是依照官方的介紹安裝一邊。
http://www.postgresq
* postgresql-client-9.1 - client libraries and client binaries
* postgresql-9.1 - core database server
* postgresql-contrib-9.1 - additional supplied modules
* libpq-dev - libraries and headers for C language frontend development
* postgresql-server-dev-9.1 - libraries and headers for C language backend development
* pgadmin3 - pgAdmin III graphical administration utility
僅僅要把命令行裏的postgresql-9.1 替換爲如下包的名字就能夠。例如說。需要安裝postgresql-client-9.1,就輸入
sudo apt-get install postgresql-client-9.1
如下的都同樣。
安裝完postgresql之後。需要對數據庫進行一些設置。例如說加入role,以及建立數據庫等。詳細方法例如如下:
設置postgresql 的用戶以及密碼
sudo -u postgres createuser
而後依照提示加入用戶
第一個提示是輸入username,而後問這個用戶是否是超級用戶。是否是贊成建立數據庫。是否是贊成加入新的用戶。依照需要回答。就可以建立一個用戶。
建立一個數據庫
sudo -u postgres createdb mydb #mydb 是數據庫的名字,可以按本身意願設置
建立完之後用psql命令設置剛剛建立的用戶的密碼,以及賦予這個用戶權限訪問數據庫
sudo -u postgres psqlpostgres=# alter user linuxpoison with encrypted password 'password';
ALTER ROLE
postgres=# grant all privileges on database linuxdb to linuxpoison;
GRANT
以後可以使用\l看到已經成功建立的數據庫以及這個剛剛被加入的用戶以及有了權限訪問這個數據庫。
安裝psycopg2
pip install psycopg2
在需要使用到數據的時候,例如說在Django的settings.py裏,加上import psycopg2就能夠。而後在DATABASE的ENGINE裏的末尾加上postgresql_psycopg2就能夠。
windows下安裝NumPy,SciPy,matplotlib,pil, gensim, django,pandas,pydot等python拓展包
(python3自帶pip,python2要本身先安裝pip) pip install package_name
假設上面方法不能成功安裝,一般是pip安裝包時其相應的依賴包未安裝,可以嘗試如下的方法2
windows wheel安裝包下載地址[Unofficial Windows Binaries for Python Extension Packages]
Note: wheelPython 分發的新標準,意在代替 eggs。
1. 安裝whl拓展名的包需要pip,安裝pip【安裝pip】(python3自帶。不用安裝)
2. 安裝whl文件
直接在cmd中輸入安裝命令
pip install Pillow-2.7.0-cp34-none-win_amd64.whl
pip.exceptions.unsupportedwheel: *.whl is not a supported wheel on this platform.
解決1:相應的版本號出錯:如VTK-7.0.0-cp34-cp34m-win_amd64.whl表示python3 windows64位版本號的whl安裝包
解決2:假設安裝whl相應版本號正確仍是報錯。則
This can also be caused by using an out-of-date pip with a recent wheel file.
Upgrading pip with python -m pip install --upgrade pip solved it.
先下載scipy的依賴包numpy-mkl
pip install numpy-1.11.0+mkl-cp34-cp34m-win_amd64.whl
pip install scipy-0.17.1-cp34-cp34m-win_amd64.whl
1 win32下安裝pil.whl文件
下載http://www.pythonware.com/products/pil/
2 win64下安裝pil:
沒有pil安裝包,可用pillow(裏面包括pil)替代
pip install pillow
Note:gensim依賴NumPy和SciPy
1 pip安裝:
pip install gensim #python3自帶pip
2 下載原碼安裝:
https://pypi.python.org/pypi/gensim#downloads
unpack the source gensim-0.10.3.tar.gz and run
`D:\Downloads\Programming\Python\gensim-0.10.3> python setup.py install`
[scripygensimwindows64 位 安裝python 擴展包pythoncollection]
Documentation Manual for the gensim package is available inHTML. Itcontains a walk-through of all its features and a complete reference section.It is also included in the source distribution package.
[https://pypi.python.org/pypi/gensim#downloads]
pip安裝gensim時出現錯誤
#【完全解決 error: Unable to find vcvarsall.bat】
1 pip install for python 2.7:
C:\Users\pi\pip\pip.log:
Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it fromhttp://aka.ms/vcpython27
an integer is required
解釋:For Windows installations:
While running setup.py for package installations, Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path inVS90COMNTOOLS
environment variable before callingsetup.py
.
Execute the following command based on the version of Visual Studio installed:
Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%
Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%
Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%
【http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat?rq=1】
Installing gensim in windows 7
2 pip install for python3.4:
TypeError: 'str' object cannot be interpreted as an integer'str' object cannot be interpreted as an integer
解決:僅僅安裝visual studio 2010中c++就ok了
Important Note:【http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat?rq=1】
If you are using a Python version more recent than Python 2.7 (especially any Python 3.x), you most likely need a version of Visual Studio C++other than the 2008 version.
See bottom for details.
Installing Windows SDK 7.1 and then re-installing MS 2010 C++ Express Edition fixed the problem.
【https://groups.google.com/forum/#!msg/gensim/8Qe-nlBMncU/4Kl0zh4ZtuoJ】
python在windows下經過pip安裝帶有c擴展的包時,假設是python 2.7,需要vs2008。假設是python 3.x,需要vs2010。版本號錯了都不行。更別提mingw。因爲c執行時不兼容的緣由。【http://www.zhihu.com/question/26857761】
1. pip install pywin32
2. 下載安裝PyWin32庫(對windows接口的Python封裝)http://sourceforge.net/projects/pywin32/,但不能直接點Download圖標,否則下下來是一個Readme.txt,點「Browse All Files」尋找需要的版本號。
Note:安裝pywin32後就可以import win32crypt, win32com等接口了,成功安裝後site-packages文件夾中多出的文件:
需要先安裝graphviz [http://www.graphviz.org/Download_windows.php],並在path中設置graphviz路徑
和安裝pyparsing [pip install pyparsing]
python2下可以直接pip安裝
pip install pydot
python3下安裝會出現版本號問題:import error
主要是版本號不兼容的問題。ubuntu下可以apt-get upgrade一下。問題解決。
windows下可以安裝pydot3k: pip install pydot3k
再import pydot
[PyQt教程 - pythonQt的安裝和配置及版本號間差別 ]
from:http://blog.csdn.net/pipisorry/article/details/39902327
ref:pip常用命令
Ubuntu-Python2.7安裝 scipy,numpy,matplotlib