Package installation fails with pip for Python3

Hello,

I want to install some additional packages for Python3 (e.g., NumPy, xmltodict, argparse, etc) on opensuse 13.2

I run

pip3 install numpy

This ends up with an error

    
"Cannot compile 'Python.h'. Perhaps you need to "

SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

Indeed, the devel package for Python3 is not installed. I attempt to change this:


>zypper in python3-devel
The following NEW package is going to be installed:
  python3-devel 


The following 2 packages are going to be upgraded:
  python3 python3-base 


2 packages to upgrade, 1 new.

Overall download size: 6.6 MiB. Already cached: 0 B  After the operation, additional 1.1 MiB will be used.
Continue? [y/n/? shows all options] (y): y

(1/3) Installing: python3-base-3.4.5-4.4.1 .............................................................................................................................................[done]
(2/3) Installing: python3-devel-3.4.5-4.4.1 ............................................................................................................................................[done]
(3/3) Installing: python3-3.4.5-4.4.1 ..................................................................................................................................................[done]

Done!

Finally, I restart the installation with pip3:


>pip3 install numpy

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
  File "/usr/lib/python3.4/site-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.4/site-packages/pkg_resources.py", line 2431, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.4/site-packages/pkg_resources.py", line 2147, in load
    '__name__'])
  File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 9, in <module>
    from pip.log import logger
  File "/usr/lib/python3.4/site-packages/pip/log.py", line 8, in <module>
    from pip import backwardcompat
  File "/usr/lib/python3.4/site-packages/pip/backwardcompat/__init__.py", line 39, in <module>
    import xmlrpc.client as xmlrpclib
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 137, in <module>
    from xml.parsers import expat
  File "/usr/lib64/python3.4/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /usr/lib64/python3.4/lib-dynload/pyexpat.cpython-34m.so: undefined symbol: _PyTraceback_Add

I have reproduced this error on three different machines - two PCs running opensuse 13.2 and one laptop running opensuse 12.x.

Reinstalling python3 with yast does not help. Compiling packages from sources without pip does not help either - I still get some “expat”-related error

Please suggest a workaround.

Thank you for your time.

Please try this and share the output if it’s still not working:

sudo pip install --force numpy

I was able to get it to work on my 13.2 test box with this command.

Thank for the hint, but its not working.

The error output looks identical to what was before.


>pip install --force numpy

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip3.4')()
  File "/usr/lib/python3.4/site-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.4/site-packages/pkg_resources.py", line 2431, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.4/site-packages/pkg_resources.py", line 2147, in load
    '__name__'])
  File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 9, in <module>
    from pip.log import logger
  File "/usr/lib/python3.4/site-packages/pip/log.py", line 8, in <module>
    from pip import backwardcompat
  File "/usr/lib/python3.4/site-packages/pip/backwardcompat/__init__.py", line 39, in <module>
    import xmlrpc.client as xmlrpclib
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 137, in <module>
    from xml.parsers import expat
  File "/usr/lib64/python3.4/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /usr/lib64/python3.4/lib-dynload/pyexpat.cpython-34m.so: undefined symbol: _PyTraceback_Add

The default development languages including Python that are available by default on openSUSE are highly tested packages for general use.

If you are either building new apps or find that an app won’t work with existing packages, then you have to install more current packages from the repository for that specific language.

It looks like the current Python3 repo for 13.2 can be installed by running the following in an elevated console

zypper in http://download.opensuse.org/repositories/devel:/languages:/python3/openSUSE_13.2/ Python3_13.2

After your repo is installed, I recommend a system update to bring everything in your openSUSE up to date including updated packages from your new repo

zypper up

Now,
I would expect that anything you’ve downloaded from the Python repos using pip should run without a problem…

If you continue to have a problem, based on your errors I’d suspect a Python3 version issue.
Post again, and whether you are interested in maintaining different versions of Python on your machine using virtualenv or not.

HTH,
TSU