Python 水蟒:无法导入pylab

Python 水蟒:无法导入pylab,python,matplotlib,pip,anaconda,Python,Matplotlib,Pip,Anaconda,我无法使用最新版本的(Linux 64位)导入pylab。其他软件包似乎工作正常。(注意:我没有sudo访问权限) 我得到: Error: No packages found matching: sip 我还发现以下错误: $ pip install sip 1 Downloading/unpacking sip You are installing a potentially i

我无法使用最新版本的(Linux 64位)导入pylab。其他软件包似乎工作正常。(注意:我没有
sudo
访问权限)

我得到:

Error: No packages found matching: sip
我还发现以下错误:

$ pip install sip                                                       1 
Downloading/unpacking sip
  You are installing a potentially insecure and unverifiable file. Future v
ersions of pip will default to disallowing insecure files.                
  Downloading sip-4.15.2.zip (899kB): 899kB downloaded
  Running setup.py egg_info for package sip
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
    IOError: [Errno 2] No such file or directory: '/tmp/pip_build_josh/
sip/setup.py'                                                             
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

IOError: [Errno 2] No such file or directory: '/tmp/pip_build_josh/sip/
setup.py'                                                                 

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build
_josh/sip                                                             
Storing complete log in /home/josh/.pip/pip.log
$pip安装sip 1
下载/解包sip
您正在安装一个可能不安全且无法验证的文件。未来v
pip的版本将默认为不允许不安全的文件。
下载sip-4.15.2.zip(899kB):已下载899kB
正在为包sip运行setup.py egg\u info
回溯(最近一次呼叫最后一次):
文件“”,第16行,在
IOError:[Errno 2]没有这样的文件或目录:'/tmp/pip\u build\u josh/
sip/setup.py'
从命令python setup.py egg_info完成输出:
回溯(最近一次呼叫最后一次):
文件“”,第16行,在
IOError:[Errno 2]没有这样的文件或目录:'/tmp/pip\u build\u josh/sip/
setup.py'
----------------------------------------
清理。。。
命令python setup.py egg_info失败,在/tmp/pip_build中出现错误代码1
_乔希/小口
在/home/josh/.pip/pip.log中存储完整的日志

想知道原因吗?

刚刚出现了这个问题,它与qt后端matplotlib试图使用的是哪一个有关,请尝试:

import PyQt4
如果你没有PyQt4,你可能有PySide

import PySide
如果是这种情况,则需要设置
matplotlib.rcParams['backend.qt4']='PySide'
而不是
'PyQt4'
。也可以在matplotlibrc文件中执行此操作(~/.matplotlib/matplotlibrc

注意:如果没有matplotlibrc文件,可以从matplotlib源目录复制该文件

import os
import matplotlib
mpl_dir = os.path.dirname(matplotlib.__file__)
os.system("cp {}/mpl-data/matplotlibrc ~/.matplotlib/".format(mpl_dir))

下面的内容对我有用

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pylab as pl

您似乎没有正确安装
PyQt
,请使用其他后端。谢谢@tcaswell。你会推荐其他后端吗?一个刺耳的(但大部分是正确的)答案是你为哪个后端安装了依赖项。请尝试
tkagg
wxagg
gtk3agg
向下滚动查看完整列表。Anaconda存在此问题的未决问题:
# find and change line:
backend.qt4 : PySide
import os
import matplotlib
mpl_dir = os.path.dirname(matplotlib.__file__)
os.system("cp {}/mpl-data/matplotlibrc ~/.matplotlib/".format(mpl_dir))
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pylab as pl