ImportError: No module named PyQt4.QtCore

前端 未结 7 1018
感情败类
感情败类 2021-02-01 18:02

I\'ve reïnstalled my ssh server, so I also need to reïnstall my Python packages.

I did that, but I still get the error:

ImportError: No module named PyQt         


        
相关标签:
7条回答
  • 2021-02-01 18:28

    Try this command to solve your problem.

    sudo apt install build-essential python3-dev libqt4-dev
    

    This works for me in python3.

    0 讨论(0)
  • 2021-02-01 18:33

    I had the same issue when uninstalled my Python27 and re-installed it.

    I downloaded the sip-4.15.5 and PyQt-win-gpl-4.10.4 and installed/configured both of them. it still gives 'ImportError: No module named PyQt4.QtCore'. I tried to move the files/folders in Lib to make it looked 'have' but not working.

    in fact, jut download the Windows 64 bit installer for a suitable Python version (my case) from http://www.riverbankcomputing.co.uk/software/pyqt/download and installed it, will do the job.

    * March 2017 update *

    The given link says, Binary installers for Windows are no longer provided.

    See cgohlke's answer at, PyQt4 and 64-bit python.

    1. Download the .whl file at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
    2. Use pip to install the downloaded .whl file.
    0 讨论(0)
  • 2021-02-01 18:37

    You don't have g++ installed, simple way to have all the needed build tools is to install the package build-essential:

    sudo apt-get install build-essential
    

    , or just the g++ package:

    sudo apt-get install g++
    
    0 讨论(0)
  • 2021-02-01 18:42

    I had the "No module named PyQt4.QtCore" error and installing the python-qt4 package fixed it only partially: I could run

    from PyQt4.QtCore import SIGNAL
    

    from a python interpreter but only without activating my virtualenv.

    The only solution I've found till now to use a virtualenv is to copy the PyQt4 folder and the sip.so file into my virtualenv as explained here: Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox?

    0 讨论(0)
  • 2021-02-01 18:48

    As mentioned in the comments, you need to install the python-qt4 package - no need to recompile it yourself.

    sudo apt-get install python-qt4

    0 讨论(0)
  • 2021-02-01 18:53

    I got the same error, when I was trying to import matplotlib.pyplot

    In [1]: import matplotlib.pyplot as plt
    ...
    ...
    ImportError: No module named PyQt4.QtCore
    

    But in my case the problem was due to a missing linux library libGL.so.1

    OS : Cent OS 64 bit

    Python version : 3.5.2

    $> locate libGL.so.1
    

    If this command returns a value, your problem could be different, so please ignore my answer. If it does not return any value and your environment is same as mine, below steps would fix your problem.

    $> yum install mesa-libGL.x86_64
    

    This installs the necessary OpenGL libraries for 64 bit Cent OS.

    $> locate libGL.so.1
    /usr/lib/libGL.so.1
    

    Now go back to iPython and try to import

    In [1]: import matplotlib.pyplot as plt
    

    This time it imported successfully.

    0 讨论(0)
提交回复
热议问题