Using modules from Debian "python3-..." packages with locally compiled Python 3.3

Terry Reedy tjreedy at udel.edu
Tue May 8 18:46:43 EDT 2012


On 5/8/2012 3:13 PM, Edward C. Jones wrote:
> I use up-to-date Debian testing (wheezy), amd64 architecture. I downloaded,
> compiled and installed Python 3.3.0 alpha 3 (from python.org) using
> "altinstall". Debian wheezy comes with python3.2 (and 2.6 and 2.7). I
> installed the Debian package "python3-bs4" (BeautifulSoup4 for Python3).

Your problem with bs4 seems to be that it got installed in a way that 
3.2 could find it and 3.3 could not.

> 1. Put bs4.pth in /usr/local/lib/python3.3/site-packages. This file should
> contain the line:
> /usr/lib/python3/dist-packages
> This works.

As it should, being the standard alternative to putting the module in 
site-packages.

> 2. At the start of each Python program using bs4:
> import sys
> sys.path.append('/usr/lib/python3/dist-packages')
> import bs4
> This works.

Another standard methods.

> 3. In the Python 3.3 source code, do ".configure" then edit
> Modules/Setup to
> contain
> SITEPATH=:/usr/lib/python3/dist-packages
> Finish compiling and altinstalling python. "import bs4" works.

An option only for those who compile. The two above work on windows for 
those who do not.

> The last is the best because I only have to do it once.

The .pth entry is also once only.

 > Next I tried numpy.  It is installed from Debian package "python3-numpy".

I bet the Debian packager has not tested the python packages with 3.3ax 
yet. On Windows, compiled packages don't work with new Python versions. 
On *nix, things are better but not necessarily perfect.

 > If I compile and install Python 3.3 _with_ the
> change in (3) above, I get:
>
>  > python3.3
> Python 3.3.0a3 (default, May 8 2012, 14:43:28)
> [GCC 4.6.3] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import numpy
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<frozen importlib._bootstrap>", line 1015, in _find_and_load
> File "<frozen importlib._bootstrap>", line 634, in load_module
> File "<frozen importlib._bootstrap>", line 294, in
> module_for_loader_wrapper
> File "<frozen importlib._bootstrap>", line 522, in _load_module
> File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 137, in
> <module>
> from . import add_newdocs
> ImportError: cannot import name add_newdocs

In this case, the problem in Python rather than C code.

> "add_newdocs.py" is present in the numpy directory.
> The "import numpy" works for the Debian python 3.2.
> What is the problem?

Question 1: if you use the .pth method, do you get the same result? (I 
expect you will, but good to check.)

Question 2: has anyone successfully run numpy with 3.3 on Debian or 
anything else? If no one here answers, try Debian or numpy lists.

Comment: the import machinery is heavily revised for 3.3. I believe 
<frozen importlib._bootstrap> is new. I believe relative imports may 
have been changed to fix bugs. One could have been introduced (though 
there are no reports on the tracker). If so, we need to fix it. Or 
perhaps there is something special about __init__ I am not aware of.

-- 
Terry Jan Reedy




More information about the Python-list mailing list