解决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.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 安装python拓展包pexpect相关的知识,希望对你有一定的参考价值。
本机(WWindows)导入正常:
D:\HB\Python\python2\pexpect-2.3>C:Python27\python.exe setup.py install
running install
running build
running build_py
creating build
creating build\lib
copying pexpect.py -> build\lib
copying pxssh.py -> build\lib
copying fdpexpect.py -> build\lib
copying FSM.py -> build\lib
copying screen.py -> build\lib
copying ANSI.py -> build\lib
running install_lib
copying build\lib\ANSI.py -> C:\Python27\Lib\site-packages
copying build\lib\fdpexpect.py -> C:\Python27\Lib\site-packages
copying build\lib\FSM.py -> C:\Python27\Lib\site-packages
copying build\lib\pexpect.py -> C:\Python27\Lib\site-packages
copying build\lib\pxssh.py -> C:\Python27\Lib\site-packages
copying build\lib\screen.py -> C:\Python27\Lib\site-packages
byte-compiling C:\Python27\Lib\site-packages\ANSI.py to ANSI.pyc
byte-compiling C:\Python27\Lib\site-packages\fdpexpect.py to fdpexpect.pyc
byte-compiling C:\Python27\Lib\site-packages\FSM.py to FSM.pyc
byte-compiling C:\Python27\Lib\site-packages\pexpect.py to pexpect.pyc
byte-compiling C:\Python27\Lib\site-packages\pxssh.py to pxssh.pyc
byte-compiling C:\Python27\Lib\site-packages\screen.py to screen.pyc
running install_egg_info
Writing C:\Python27\Lib\site-packages\pexpect-2.3-py2.7.egg-info
D:\HB\Python\python2\pexpect-2.3>
linux后台导入出错:
SR5S1:/opt/osmu_auto_script/pexpect-2.3 # python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in ?
from distutils.core import setup
ImportError: No module named distutils.core
提示没有distutils.core这个模块 请问下这个怎么解决???
多谢你的解答
那distutils.core这个模块是什么呢? 要怎么安装?
Distutils:它可以用来建立简单的windows安装程序,再加上扩展程序py2exe,就能建立独立的windows可执行程序了。
下载安装python-distutils这个包
直接安装拓展包默认路径:
Unix(Linux)默认路径:/usr/local/lib/pythonX.Y/site-packages
Windows默认路径:C:\\PythonXY\\Lib\\site-packages
查看pip安装时对应的Python版本
which pip
/d/python3.4.2/Scripts/pip
更新pip:
python -m pip install --upgrade pip
运行 python
然后import ×××,没有提示错误就说明安装成功
1. pip freeze | grep package_name
2. pip list
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 还不具备真正的依赖分析, 只是简单地为项目匹配第一需求。
requests==1.2.0
Flask==0.10.1
numpy
Note: 不指定版本则安装最新版本,也不要==符号。
pip install -r requirements.txt
sed -i ‘s/==.*$//g‘ requirements.txt 安装最新版本要去除后面的==再安装
使用pip freeze
$ pip freeze > requirements.txt
pip的freeze命令保存了保存当前Python环境下所有类库包,其它包括那些你没有在当前项目中使用的类库。 (如果你没有的virtualenv)。
但有时你只想将当前项目使用的类库导出生成为 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命令查看,搜索安装到何处
[email protected]:~#dpkg -L python-opencv
/.
/usr
/usr/share
/usr/share/python-support
/usr/share/python-support/python-opencv.public
/usr/share/doc
/usr/share/doc/python-opencv
/usr/share/doc/python-opencv/copyright
/usr/share/pyshared
/usr/share/pyshared/cv.py
/usr/lib
/usr/lib/pyshared
/usr/lib/pyshared/python2.7
/usr/lib/pyshared/python2.7/cv2.so
/usr/share/doc/python-opencv/changelog.Debian.gz
测试opencv安装好没:
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,然后按Configure按钮,并根据需要设置各个编译选项,最后点Generate按钮,退出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.postgresql.org/download/linux/ubuntu/
* 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
然后按照提示添加用户
第一个提示是输入用户名,然后问这个用户是不是超级用户,是不是允许创建数据库,是不是允许添加新的用户。按照需要回答,就可以创建一个用户。
创建一个数据库
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
Unable to find vcvarsall.bat
‘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】
3Difficulty installing Gensim using from source and pip
[http://blog.csdn.net/pipisorry/article/details/39902327]
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
Mountail Lion 上的 Python 科研环境的搭建
以上是关于linux 安装python拓展包pexpect的主要内容,如果未能解决你的问题,请参考以下文章
python linux交互模块(paramikofabric与pexpect)
linux和windows下安装python拓展包及requirement.txt安装类库
linux和windows下安装python拓展包及requirement.txt安装类库