How to install PyQt on Ubuntu 12.04 with python 2.7? - python-2.7

There may be some similar questions like this one, but I didn't find any answer for me.
I tried some ways to do it like:
sudo aptitude install python-qt4-dev python-sip4 python-sip4-dev
from: https://groups.google.com/forum/#!topic/mnemosyne-proj-devel/VQQzjhARWoA
I tried:
sudo aptitude install python-qt4
from: http://www.saltycrane.com/blog/2008/01/how-to-install-pyqt4-on-ubuntu-linux/
Every time after above installations I got error:
$python2.7
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4
I also tried to install it from source downloading PyQt4 from:
http://www.riverbankcomputing.co.uk/software/pyqt/download
and sip from: http://www.riverbankcomputing.co.uk/software/sip/download
Then I got error tring to install PyQt4:
$ sudo python configure.py --verbose
Determining the layout of your Qt installation...
/usr/bin/qmake -o qtdirs.mk qtdirs.pro
make -f qtdirs.mk
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -o qtdirs.o qtdirs.cpp
qtdirs.cpp:1:28: fatal error: QCoreApplication: No such file or directory
compilation terminated.
make: *** [qtdirs.o] Error 1
Error: Failed to determine the layout of your Qt installation. Try again using
the --verbose flag to see more detail about the problem.
My question is: What is proper and effective way to install PyQt4 on Ubuntu 12.04?

You did in fact properly install the python bindings for Qt4 when you used:
sudo aptitude install python-qt4
You should usually use the Distribution-provided packages - the Ubuntu-provided packages are perfectly adequate for your needs.
What's puzzling me is the error you got after installing the Ubuntu package. I just tried this on a Ubuntu 12.04 installation and it worked for me. That suggests to me that your current installation of Ubuntu on your system is broken in some way.
You could try completely purging the python-qt4 package and reinstalling it again;
sudo apt-get remove --purge python-qt4
If you also issue:
sudo apt-get clean
... that will remove any downloaded package files from the system, so that apt will then download the package file again when you issue a
sudo apt-get install python-qt4
If that still doesn't work, then something very odd indeed is going on with your Ubuntu installation, and it might be wise to completely reinstall Ubuntu.

On aws ubuntu (12.04 and 14.04):
sudo apt-get update
sudo apt-get install python-qt4
sudo apt-get install libxml2-dev libxslt1-dev python-dev
sudo apt-get install python-lxml
sudo apt-get install xvfb
Check this link and generate your-own-example.py
DISPLAY=localhost:1.0 xvfb-run python your-own-example.py
Voila.

Related

Getting error while installing memsql python library "_mysql.c:44:10: fatal error: 'my_config.h' file not found" on MAC OSx

When am trying to install the memsql python library getting below error
I have tried the below options already:
sudo pip install memsql
sudo pip install memsql --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"
Installing collected packages: MySQL-python, memsql
Running setup.py install for MySQL-python ... error
Complete output from command /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-JDxMyP/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib install --record /private/tmp/pip-record-azfFw0/install-record.txt --single-version-externally-managed --compile:
running build_ext
building '_mysql' extension
creating build
creating build/temp.macosx-10.14-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/8.0.15/include/mysql -I/usr/local/opt/openssl/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.14-intel-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1}
In order to install memsql-python you need to ensure that you have the dependencies already available. Specifically, the dependency that seems to be missing from your environment is libmysqlclient-dev or an equivalent package.
Note - you are overriding the include paths to point at your openssl installation which may be causing this issue due to how the compiler is searching for development headers.
According to the project's readme, use the following steps to get started quickly on Ubuntu:
sudo apt-get update
sudo apt-get install -y mysql-client python-dev libmysqlclient-dev python-pip
sudo pip install memsql
Use the following steps to get started with RHEL based distributions such as Amazon Linux or Centos:
sudo yum update
sudo yum install -y gcc mysql-devel
sudo pip install memsql
-- edit to address question regarding installation on Mac OSX
On a Mac it appears that you can install the mysql-client package from brew which in theory should provide the libmysqlclient-dev package. Once available try installing the memsql-python package without overriding linker flags since memsql-python should build fine without openssl. If you need openssl support then you will need to ensure that both the openssl and libmysqlclient-dev shared objects are available to the linker at compilation time.
This procedure worked for me:
brew remove mysql
brew install mysql#5.7
brew link --force mysql#5.7
I read a post and adjusted the procedure to link things in the /usr/local/bin instead of adding a new route to the PATH variable.
Reference: MacOS: "pip install MySQL-python" returning an error: "_mysql.c:44:10: fatal error: 'my_config.h' file not found"

django channels install error

I am trying to create a one to one real-time messaging system using Django. Upon searching I found out about django-channels. So i created a virtual env with python 3.5 and latest Django but when I do pip install channels I get :
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/kshitij/Documents/projects/personal/maker/venv/include/python3.5m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.5/src/twisted/test/raiser.o
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
probably because of missing python headers so i did : sudo apt-get install python3-dev but it still shows the same error. What should I do?
pip version: 18
python version: 3.5
django version: 2.1
I tried doing sudo apt-get install python3-dev but getting:
ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'
Verify your pip is not pip and its pip3.
You may also try installing sudo apt install python3.X-dev.
For you, it's sudo apt install python3.5-dev
Try installing the Linux compiler and python3-dev:
sudo apt install gcc
sudo apt install python3-dev
pip install channels
The last error may indicates you have an issue caused by many python versions installed on your system (see this answer). You should make sure you don't have incomplete or corrupted python installation on your system (did you already compiled Python by yourself?). In addition, make sure the package python3 is correctly installed or sudo apt-get install python3-dev cannot succeed.
In addition, you may try to locate Python.h on your system. Make sure each Python.h on your system correspond to a valid python setup (you may have one for python 2 and one more for python 3).

Install g++ 4.9 on Mint 17.2

I'm trying to install g++ 4.9 or greater in order to build mapbox on Android. The instructions state I need g++ 4.9 or greater. I found the following instructions, but they don't work.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
The last command says:
~ $ sudo apt-get install g++-4.9
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package g++-4.9 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'g++-4.9' has no installation candidate
I also tried from Synaptic Package Manager and got the following:
g++:
Depends: cpp (>=4:4.9-1ubuntu7) but 4:4.8.2-1ubuntu6 is to be installed
Depends: gcc (>=4:4.9-1ubuntu7) but 4:4.8.2-1ubuntu6 is to be installed
Depends: g++-4.9 (>=4.9) but it is not installable
Depends: gcc-4.9 (>=4.9) but it is not installable
How can I get g++ 4.9 on my computer?
Thanks.
Here is how to install g++-4.9 on Linux Mint 17.2 Rafaela
Go to menu -> Administration -> Software sources
Click on Additional repositories and then Getdeb
Click on Edit URL...
Replace deb http://archive.getdeb.net/ubuntu trusty-getdeb apps
by
deb http://archive.getdeb.net/ubuntu wily-getdeb apps
and click on Update the cache
At this point you can go with
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
You can invoke your g++ like this:
g++-4.9
Now you have g++ 4.9.3 installed
And as an add, you can have the latest g++-5 (g++ 5.2.1) compiler
sudo apt-get install g++-5

How to change arm version in arm-linux-gnueabi-gcc for cross compile

I want to cross-compile in eclipse for board armv7l.
I got the armv7l via, uname -i.
I installed ARM cross compiler toolchain, using below commands.
$ sudo apt-get install emdebian-archive-keyring
$ sudo apt-get install libc6-armel-cross libc6-dev-armel-cross
$ sudo apt-get install binutils-arm-linux-gnueabi
$ sudo apt-get install gcc-arm-linux-gnueabi
$ sudo apt-get install g++-arm-linux-gnueabi
$ sudo apt-get install u-boot-tools
$ sudo apt-get install libncurses5-dev
I think I have to give an option for my target board version.
First time I tried to put arm-linux-gnueabi-g++ in C/C++ Build->settings->GCC C++ Compiler and GCC C++ Linker.(eclipse project properties)
Next I put -march=armv7 in Miscellaneous
But it was not working. I checked the executable file with readelf -A
and it shows this
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3-D16
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_CPU_unaligned_access: v6
Tag_DIV_use: Not allowed
What option I have to put for my target board ?

Python pip can't seem to find Python.h despite python-dev installed

I am currently trying to install getch, a simple python package and have run into quite a bit of difficulty. I recently installed pypy in a kind of messy way (I wanted to get numpy with pypy working, which was a considerable pain) so that might have to do with the problem I'm having.
Okay, so I try to run
sudo pip install getch
and I get the error...
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
and as a bonus, a character encoding error.
This is the error that folks get when they don't have python-dev installed. However, I do. I attempted to work around this issue, by downloading the package and installing it manually.
sudo python setup.py install
also gave me the gcc error from above. I have gcc installed, and x86_64-linux-gnu-gcc works in terminal fine. I made a simple hello world program in c that simply includes Python.h. That worked fine as well. After remove --purging pypy, python, and python-dev from my system, I re-installed just python and python-dev and I still have the same silly issue.
Anyone have any thoughts?
Here's a pastebin of the exact error I'm getting. pastebin.com/mjRdADZx
You need to manually download the Python 2 version and install it. The version downloaded by pip is for Python 3.
The clue is this line:
Downloading/unpacking getch
Downloading getch-1.0.tar.gz # This is the Python 3 package
Running setup.py egg_info for package getch
Installing collected packages: getch
Running setup.py install for getch
building 'getch' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include -I/usr/include/python2.7 -c getchmodule.c -o build/temp.linux-i686-2.7/getchmodule.o
getchmodule.c: In function ‘getch_getche’:
getchmodule.c:36:6: warning: unused variable ‘ok’ [-Wunused-variable]
getchmodule.c: In function ‘getch_getch’:
getchmodule.c:43:6: warning: unused variable ‘ok’ [-Wunused-variable]
getchmodule.c: At top level:
getchmodule.c:54:15: error: variable ‘getchmodule’ has initializer but incomplete type
getchmodule.c:55:4: error: ‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function)
The Python 2 version is also 1.0, but the file name is getch-1.0-python2.tar.gz. You can download it directly from the index.
Once downloaded, extract the archive and then python setup.py install from within the extracted directory.