Issue #2 resolved

Import module errors with pip install

Richard Penman
created an issue


I installed stackless via pip on Ubuntu 13.04 but had difficulty importing python2.7 modules:

$ pip install stackless-python
$ slpython2.7
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 563, in <module>
  File "/usr/lib/python2.7/", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/", line 578, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/", line 524, in get_config_vars
  File "/usr/lib/python2.7/", line 408, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

Tried fixing with a symlink:

$ cd /usr/lib/python2.7
$ ln -s plat-x86_64-linux-gnu/ .
$ slpython2.7
>>> import sys
>>> import csv
Traceback (most recent call last):
  File "", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/", line 7, in <module>
    from functools import reduce
  File "", line 10, in <module>
    from _functools import partial, reduce
ImportError: No module named _functools

Python package versions attached:

dpkg -l | grep -i '^ii.*python' > dpkg.txt

find /usr/lib/python2.7 -type f > python.txt

The python paths:

$ python -S -c 'import sys; print repr(sys.path)'
['', '/usr/lib/python2.7/', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload']

$ slpython2.7 -S -c 'import sys; print repr(sys.path)'
['', '/usr/lib/', '/usr/lib/python2.7/stackless-packages', '/usr/lib/python2.7/', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload']

Comments (6)

  1. Anselm Kruis repo owner

    Finally I got time and access to a Debian testing system. The issue was caused by the new multiarch installation scheme.

    It is fixed by changeset 3023c9592d3a. Installers starting with Stackless 2.7.6r3 contain the fix.

  2. Anselm Kruis repo owner

    I'm not exactly sure, if I understand you problem. If you execute a "pip install stackless-python" a two stage installation happens:

    1. Pip fetches and installs the "stackless-python" installer from pypi

    2. The "stackless-python" installer detects your C-Python-version, OS, CPU-Architecture and Unicode-width. Then it causes pip to install the appropriate package from (The technical details are a bit more involved.)

    This second step amends your existing Python installation with Stackless specific files. Therefore the version numbers of C-Python and Stackless should match. For instance, you better don't install a Stackless 2.7.8 into a C-Python 2.7.3. If your distribution ships an old C-Python, better compile Stackless from source.

    If you can't compile Stackless for any reason, you can install a newer Stackless into an older C-Python. Usually it works fine. For instance:

    # Create a new virtual environment
    $ cd /tmp
    $ python2.7 ~/src/virtualenv-1.9.1/ test
    New python executable in test/bin/python2.7
    Also creating executable in test/bin/python
    Installing setuptools............done.
    Installing pip...............done.
    kruis@uranos $ . test/bin/activate
    (test)$ python2.7
    Python 2.7 (r27:82500, Aug 07 2010, 16:54:59) [GCC] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    # C-Python is a 2.7.0
    # Install the Stackless installer for 2.7.8 into the virtual env
    (test)$ pip install
      Downloading stackless_installer_C4_linux_x86_64- (2.3MB): 2.3MB downloaded
      Running egg_info for package from
    Installing collected packages: stackless-installer-C4-linux-x86-64
      Running install for stackless-installer-C4-linux-x86-64
        Installing install-stackless script to /tmp/test/bin
        Installing uninstall-stackless script to /tmp/test/bin
    Successfully installed stackless-installer-C4-linux-x86-64
    Cleaning up...
    # Now you have a new command install-stackless. It performs the real installation
    (test)$ which install-stackless
    (test)$ install-stackless
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/linux-x86_64/slpython2.7 -> /tmp/test/bin
    creating /tmp/test/bin/lib.stackless
    creating library /tmp/test/bin/lib.stackless/
    creating /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/ -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/stackless.pyc -> /tmp/test/lib64/python2.7/stackless-packages
    creating /tmp/test/lib64/python2.7/stackless-packages/distutils
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/distutils/ -> /tmp/test/lib64/python2.7/stackless-packages/distutils
    creating /tmp/test/lib64/python2.7/stackless-packages/distutils/command
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/distutils/command/ -> /tmp/test/lib64/python2.7/stackless-packages/distutils/command
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/distutils/command/build_ext.pyc -> /tmp/test/lib64/python2.7/stackless-packages/distutils/command
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/distutils/command/ -> /tmp/test/lib64/python2.7/stackless-packages/distutils/command
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/distutils/command/__init__.pyc -> /tmp/test/lib64/python2.7/stackless-packages/distutils/command
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/distutils/__init__.pyc -> /tmp/test/lib64/python2.7/stackless-packages/distutils
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/ -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/ -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/platform.pyc -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/ -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/copy_reg.pyc -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/pickle.pyc -> /tmp/test/lib64/python2.7/stackless-packages
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/ to copy_reg.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/ to platform.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/ to pickle.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/ to stackless.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/distutils/ to __init__.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/distutils/command/ to __init__.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/distutils/command/ to build_ext.pyc
    # Stackless is now available
    (test)$ which slpython2.7
    (test)$ slpython2.7
    Python 2.7.8 Stackless 3.1b3 060516 (default, Jul  7 2014, 17:12:02) 
    [GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.

    Of course I don't guarantee in any way, that the Stackless 2.8.7 is compatible with the existing 2.7.0 installation.

    Regards Anselm

    Am 16.07.2014 14:51, schrieb Michael Bravo:

  3. Michael Bravo

    My problem is like this: I have a stock up-to-date Debian Wheezy system, with native python 2.7.3

    Stackless python is installed via pip. It has the problem described in this issue, for example:

    Install package syncless via pip. It works fine with plain python; however on import under slpython2.7 it can't find system modules such as time

    I was wondering if it would be possible to retrofit your fix mentioned here by, say, pip install --upgrade stackless-python

  4. Anselm Kruis repo owner

    Michael Bravo

    My problem is like this: I have a stock up-to-date Debian Wheezy system, with native python 2.7.3

    Stackless python is installed via pip. It has the problem described in this issue, for example:

    Unless you get exactly this exception: ImportError: No module named _sysconfigdata_nd your problem is not the problem reported in this issue.

    If you get a different exception, please open a new issue and add the output of python -c 'import sys; print sys.path' and slpython2.7 -c 'import sys; print sys.path'. Do you use virtualenv?

  5. Log in to comment