ubuntu14.04环境下spyder的安装

在ubuntu14.04系统中,默认在/usr/lib目录下安装了python2.7.6和python3.4.3,在该环境下安装spyder,然后使其链接到python3.4.3。

首先安装为python3安装模块下载工具pip3,然后安装spyder的依赖包PyQt5和sphinx。刚开始的时候直接安装了PyQt4,然后会报错,无法找到QT binding。

1,安装pip3

参考:https://ft.wupo.info/pip3-python3-install-module/

sudo apt-get install python3-setuptools
sudo easy_install3 pip

安装完成pip3之后,就开始安装spyder。

2,安装spyder

参考:http://stackoverflow.com/questions/28518830/install-spyder-for-python3-4-ubuntu

但是这个链接里面的安装是python-qt4和安装后关联的是python2,所以需要我们需要的版本是pyqt5,所以安装python3-pyqt5,但该命令行只安装了pyqt5的主要模块,但在运行spyder的时候需要其他模块,所以将其他模块也进行安装

sudo apt-get install python3-pyqt*

sudo apt-get install python3-pyqt5 python-sphinx


sudo apt-get install python3-pyqt*
sudo pip3 install spyder

3,一些问题

(1)在安装spyder过程中出现以下问题:

error: command 'i686-linux-gnu-gcc' failed with exit status 1

参考http://blog.csdn.net/niyingxunzong/article/details/13094875

在终端输入:

sudo apt-get install python-dev

问题就解决了。

(2)输入spyder打开软件的时候,出现

pkg_resources.ContextualVersionConflict: (six 1.5.2 (/usr/lib/python3/dist-packages), Requirement.parse('six>=1.9.0'), {'prompt-toolkit'})

问题在于系统的six模块是1.5.2版本的,而运行spyder需要1.9.0版本,对six进行升级即可。

sudo pip3 install -U six

(3)关于PyQt版本的问题

在安装的过程中,刚开始安装的是pyqt4的版本,此时在启动spyder出现错误,无法找到pyside,然后在处理该错误时又出现了无法找到QT链接的问题,这个问题的关键在于pyqt的版本问题,在python3.4的模块的安装目录下,即/usr/local/lib/python3.4/dist-packages/qtpy中可以找到出错的文件__init__.py,在该文件中可以看到说明

**QtPy** is a shim over the various Python Qt bindings. It is used to write
Qt binding indenpendent libraries or applications.

The shim will automatically select the first available API (PyQt5, PyQt4 and
finally PySide).

You can force the use of one specific bindings (e.g. if your application is
using one specific bindings and you need to use library that use QtPy) by
setting up the ``QT_API`` environment variable.

PyQt5
=====

For PyQt5, you don't have to set anything as it will be used automatically::

    >>> from qtpy import QtGui, QtWidgets, QtCore
    >>> print(QtWidgets.QWidget)


PyQt4
=====

Set the ``QT_API`` environment variable to 'pyqt' before importing any python
package::

    >>> import os
    >>> os.environ['QT_API'] = 'pyqt'
    >>> from qtpy import QtGui, QtWidgets, QtCore
    >>> print(QtWidgets.QWidget)

PySide
======

Set the QT_API environment variable to 'pyside' before importing other
packages::

    >>> import os
    >>> os.environ['QT_API'] = 'pyside'
    >>> from qtpy import QtGui, QtWidgets, QtCore
    >>> print(QtWidgets.QWidget)

"""

QtPy主要是选择一个合适的QT binding,包括PyQt5,PyQt4和PySide,默认的是PyQt5,但是安装的版本是PyQt4,所以启动spyder会出错,上面的提示可以设置QT_API这个环境变量来选择版本,但是试验过之后仍然无法启动spyder,最后安装了PyQt5才解决该问题。

(4)python模块安装路径问题

目前有两个

usr/local/lib/python3.4/dist-packages/和usr/lib/python3/dist-packages/,这两个对应的都是python3模块的安装路径,模块安装方法有:

a,sudo apt-get install + 模块名

b,sudo pip3 install + 模块名