Build a PyQt environment under Ubuntu12.10

Source: Internet
Author: User
Build the PyQt environment under Ubuntu12.10. Step 1: Download The Qt4 source code Step 2: Download the SIP (SIPisatoolforautomaticallygeneratingPythonbindingsforCandC ++ libraries) Step 3: step 4: Configure

Build a PyQt environment in Ubuntu 12.10.

Make

Install Python (this version has Python2.7 and Python3.2 by default)

Step 1: Download the source code of Qt4

Step 2: Download SIP (SIP is a tool forautomatically generating Python bindings for C andC ++ libraries)

Step 3: Download PyQt

Step 4: configure the SIP:

Decompress the sip-xxxxx.tar.gz package and go to the sip-XXXXX directory.

Run

Python configure. py

Note:: If you have multiple versions of Python installed then make sure

You use theinterpreter for which you wish SIP to generate bindings.

That is to say, if I use Python3.x for development, the command used is:Python3 configure. py

The result in shell is:

Lieo @ ubuntu :~ /Download/sip-4.14.2 $ python3 configure. py
This is SIP 4.14.2 for Python 3.2.3 on linux2.
The SIP code generator will be installed in/usr/bin.
The sip module will be installed in/usr/lib/python3/dist-packages.
The sip. h header file will be installed in/usr/include/python3.2mu.
The default directory to install. sip files in is/usr/share/sip.

Make

Note:In this step, the Python. h file cannot be found. (skip to make install if no error is reported)

This is because header files and static library packages are missing,

If you use python2.7 to run

Sudo apt-get install python-dev

Run Python 3

Sudo apt-get install python3-dev

Make install

Step 5: Compile and install Qt4

Ubuntu has no compiling environment by default. Run the following command to install the compiling environment:

Sudo apt-get install build-essential

# Enter the qt source code directory to run

./Configure

Result:Qt will be installed/Usr/local/Trolltech/Qt-4.8.4

Make
Make install

1. If the following error occurs in the./configure stage:
Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11
That's because there is noLibxtst-dev, Use the command apt-get install libxtst-dev to install

2. If an error occurs during the make stage

/Usr/bin/ld: cannot find-lXrender
Make [1]: *** [../lib/libQtWebKit. so.4.7.3] Error 1

Make: *** [sub-webkit-make_default-ordered] Error 2

That's because it is not installed.Libxrender-dev

3. In qt create, try to compile the test. If qmake cannot be found, manually set the qmake position in tool-Option-QT4. The default qmake location is in/usr/local/Trolltech/Qt-4.8.4/bin/qmake.

After these steps are complete, put "PATH =/usr/local/Trolltech/Qt-4.8.4/bin: $ PATH
The export PATH is added to. profile, and Qt is successfully installed.
Or Add the following lines in the. bashrc file (If your shell is bash, ksh, zsh, or sh:
QTDIR =/usr/local/Trolltech/Qt-4.8.4
PATH = $ QTDIR/bin: $ PATH
LD_LIBRARY_PATH = $ QTDIR/lib: $ LD_LIBRARY_PATH

Step 6: Install PyQt

# Go To The PyQt source code directory and run the following command to install PyQt
# Ensure that Qt4 and SIP are correctly installed
Python configure. py
Make
Make install

This configuration is complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.