Debian 7.4 - LXML compilation failed with Python 3.4.0 - compilation

I've just installed Debian 7.4 on my PC. I need python 3.3.2 or higher AND python3-lxml for my inner developments. As python 3.2 is the base line for the python3.x series in debian wheezy Ive' compiled a 3.4.0 python version and uninstalled the old 3.2. (note that the process also un-installed some gnome dependencies).
After that work Python3 packages (cherrypy for example) install fine and modules can be successfully imported inside the interpreter.
When trying to install python3-lxml , the system needs to install the lxml repository dependencies python3.2 ... that I just don't want to.
So I decided to compile lxml over python 3.4.0.
Dependencies installed :
* libxml2 >= 2.7.8
* libxml2-dev
* libxslt1= >= 1.1.26
* libxslt1-dev
sudo apt-get install libxml2 libxml2-dev libxslt1 libxslt1-dev
I think that only the *-dev packages are required, aren't they ?
The problem is that I faced this issue while compiling in the source directory :
jeby6372#mercure:~/Pack/lxml-3.3.4$ sudo python3 setup.py build
Building lxml version 3.3.4.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
/opt/python-3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
running build
running build_py
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-3.4/lxml/includes
running build_ext
building 'lxml.etree' extension
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/home/jeby6372/Pack/lxml-3.3.4/src/lxml/includes -I/opt/python-3.4.0/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
gcc -pthread -shared build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -L/usr/lib -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-3.4/lxml/etree.cpython-34m.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
the -lz option is not recognized by the gcc. For information i've install the tool chain with :
sudo apt-get install build-essential
Any idea ?
In advance thanks for your help.

The linker can't find libz when trying to compile the python c-extension. I believe you need the zlib dev package on Debian. Try apt-get install zlib1g-dev and then try and rebuild.

You're right Photoionized,
while installing another package (setuptools) it claims for the zlib python module that must be set at compile time. Don't now why but I thought it was a similar problem as the unknown -lz option that sounds like Library Zlib ?
So I installed the zlib1g librairy and its sources , compile again the python-3.4.0 with the --with-zlib option.
./compile --prefix=opt/python-3.4.0 --with-zlib
make
sudo make install
then create a new link to the command
sudo rm /usr/bin/python3 && ln -s /usr/bin/python3 /opt/python-3.4.0/bin/python3.4m
After that the installation ended succesfully in the lxml source directory
sudo python3 setup.py install
Thanks again for your answer

Related

How to deal with "clang: error: unsupported option '-fopenmp'" on travis?

I am currently trying to deploy a project using openmp. I have the flag '-fopenmp' on Travis.
How could I fix that ?
In local I just brew install libopenmp which solved the issue. But not on Travis, what are the options ?
Using cython I got the following ".travis.yml"
os: linux
dist: xenial
language: python
python:
- "3.7"
cache: pip
addons:
apt:
packages:
- patchelf
matrix:
include:
- os: osx
# No version of Python is available via virtualenv on OS X workers, see https://github.com/travis-ci/travis-ci/issues/2312
language: generic
env: TOXENV=py37
fast_finish: true
before_install:
brew install libomp
install:
- pip install --upgrade "pip < 19.1" -r CI/requirements.txt
- python setup.py develop
script:
- pytest
Travis fails while executing :
clang -fno-strict-aliasing -fno-common -dynamic -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/openssl#1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python#2/2.7.17/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cpt/alphabet.c -o build/temp.macosx-10.13-x86_64-2.7/cpt/alphabet.o -fopenmp
While in local it compiles with python 3.7, how could I fix that aswell ?
On apple's llvm, -fopenmp is not supported. One should use brew's llvm.
The following ables to link openmp:
- brew install llvm libomp
- export CPP=/usr/local/opt/llvm/bin/clang;
For reference, the issue where there are all the commands: https://github.com/bluesheeptoken/CPT/issues/68#issuecomment-563342866

Psycopg2 fails to install on python 3 with pip issuing a fatal error

$ yum install python3 postgresql python-devel libpqxx-devel
Loaded plugins: langpacks, refresh-packagekit
Package python3-3.3.2-8.fc20.x86_64 already installed and latest version
Package postgresql-9.3.2-2.fc20.x86_64 already installed and latest version
Package python-devel-2.7.5-9.fc20.x86_64 already installed and latest version
Package 1:libpqxx-devel-3.2-0.5.fc20.x86_64 already installed and latest version
Nothing to do
I am trying to install psycopg2 in my virtualenv to connect django with the postgresql database.
In Fedora 19 and postgresql-9.2 the path to pg_config was:
/usr/pgsql-9.2/bin
In Fedora 20, this directory does not exist.
However pg_config can be found in /usr/bin/pg_config.
Trying to install psycopg2:
$ export PATH=$PATH:/usr/bin; pip install psycopg2
Downloading/unpacking psycopg2
Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
Running setup.py egg_info for package psycopg2
... -compiling output here- ...
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090302 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python3.3m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.3/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:27:0:
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /home/flyer/.virtualenvs/p3test/bin/python3 -c "import setuptools;__file__='/home/flyer/.virtualenvs/p3test/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mrsky4-record/install-record.txt --single-version-externally-managed --install-headers /home/flyer/.virtualenvs/p3test/include/site/python3.3 failed with error code 1 in /home/flyer/.virtualenvs/p3test/build/psycopg2
Storing complete log in /home/flyer/.pip/pip.log
I would appreciate your help.
You are missing python3 include files
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
you can probably find them in the python3-devel package.
Install the python3-devel package to get it work
sudo dnf install python3-devel
If it works then alright or if it requires libpq-fe.h file then install it using the command:
sudo dnf install postgresql-devel
On Ubuntu. I solved this with:
sudo apt-get install libpq-dev
As indicated in the other answers this is caused by not having the right Python "devel" package installed. On CentOS, the Python "devel" rpm package is numbered with the with the qualified version. For example as of this writing the current versions are:
python34-devel for epel repository
python36u-devel for ius repository
Example Yum command (assumes EPEL repository is configured):
sudo yum install python34-devel
Related answer from server fault: https://serverfault.com/questions/710354/repository-for-python3-devel-on-centos-7

Upgrade GCC 4.6.3 on Ubuntu 12.04 to 4.8.2

I'm about to update default GCC (version 4.6.3) shipped by Ubuntu 12.04 to 4.8.2, though the compilation requires a standalone C++ compiler
admin#ubuntu: /usr/local/gcc_build$ sudo make
ends up with
configure: error: C++ compiler missing or inoperational
make[2]: *** [configure-stage1-libcpp] Error 1
Therefore I turn to the process of g++ installation with a preference to the latest version, which means that I would like to compile from source directly rather than apt-get. But seriously, I can't find the source anyway!(O_o). On the other hand, does the source of GCC also come along with that of g++ in the tar file I downloaded, or not? Thanks.
PS: problem remains unsolved with admin#ubuntu: /usr/local/gcc_build$ /home/admin/gcc-4.8.2/configure --enable-languages=c,c++
Add the ppa by
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
Install g++ and gcc (version 4.8)
sudo apt-get update; sudo apt-get install gcc-4.8 g++-4.8
Run the following commands one by one,
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
That's it you are done!
You can easily compile the sources.
The following commands worked for gcc 4.7. They should be fine for gcc 4.8 as well:
sudo apt-get install libmpfr-dev libgmp3-dev libmpc-dev flex bison
svn checkout svn://gcc.gnu.org/svn/gcc/trunk
cd trunk
./configure --prefix=/opt/gcc-4.8.2/usr/local/gcc-4.8.2 --enable-languages=c,c++
make
make install
The compiler will be placed in the /opt/ directory, so you have to use it from there.
Do you want to compile it yourself ? If not, there is a PPA, described here

g++ is missing when I use codeblocks

I'm using codeblocks with fedora-16. When I try to build it starts the build but then says `"/bin/sh: g++ command not found".
If I select compile, it compiles OK.
So looking at this site they say that gcc uses g++ so I tried "gcc -c this.c" and that worked.
Does anyone have a clue as to what is going on?
In order to compile .c and .cpp files in Fedora you need to install a compiler.
To install the gcc and g++ compilers, you will need the build-essential package. This will also install GNU make.
build-essential contains a list of packages which are essential for building Ubuntu packages including gcc compiler, make and other required tools.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
Now, you should able to compile software using C / C++ compilers.
To install the manpages for c and c++ development, install the manpages-dev package.
If
$ sudo apt-get install build-essential
doesn't work, try this:
su -
yum install make automake gcc gcc-c++ kernel-devel
Codeblock invokes g++ to link the libraries.

sqlite3-ruby gem can't find sqlite3.h on ubuntu

Trying to get Rails up on ubuntu, and I’m having trouble installing sqlite3-ruby – it apparently can’t find sqlite3.h. All the references I can find to the error suggest the problem is either: sqlite3 headers aren’t installed, or make can’t find them. It looks to me like I’ve solved both those issues and I’m still seeing the same problem.
No real idea what’s going on here. Version mismatch, maybe? This is with ruby 1.8.7, sqlite 3.6.22-1, gem 1.3.5 and sqlite3-ruby 1.3.1 on ubuntu 10.04.1.
david#li88-188:~$ sudo apt-get install sqlite3
[...successful installation...]
Setting up sqlite3 (3.6.22-1) ...
david#li88-188:~$ sudo apt-get install libsqlite3-dev
[...successful installation...]
Setting up libsqlite3-dev (3.6.22-1) ...
david#li88-188:~$ sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel'
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
[...configuration options etc....]
david#li88-188:~$ cat /var/lib/gems/1.8/gems/sqlite3-ruby-1.3.1/ext/sqlite3/mkmf.log
find_header: checking for sqlite3.h... -------------------- no
"gcc -E -I. -I/usr/lib/ruby/1.8/i486-linux -I. -I/usr/local/include -I/opt/local/include -I/usr/include -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -g -g -O2 -fPIC -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <sqlite3.h>
/* end */
--------------------
Note that /usr/include is in the list of arguments.
david#li88-188:~$ ls -l /usr/include/sqlite3.h
-rw-r--r-- 1 root root 268351 2010-02-08 03:59 /usr/include/sqlite3.h
And note that the file is there.
In my case I had to install libsqlite3-dev
sudo apt-get install libsqlite3-dev
Never mind. gcc itself wasn't installed, as I discovered when I tried to install another gem with better error messages.
https://help.ubuntu.com/community/RubyOnRails here is a basic tutorial for setting up RoR development environment for Ubuntu with each step of the way explained. Good luck!

Resources