1. Anselm Kruis
  2. slp-installer
  3. Issues
Issue #2 resolved

Import module errors with pip install

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/site.py", line 563, in <module>
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 578, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 524, in get_config_vars
  File "/usr/lib/python2.7/sysconfig.py", line 408, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", 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/_sysconfigdata_nd.py .
$ slpython2.7
>>> import sys
>>> import csv
Traceback (most recent call last):
  File "runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/csv.py", line 7, in <module>
    from functools import reduce
  File "functools.py", 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/python27.zip', '/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

    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 https://bitbucket.org/akruis/slp-installer/downloads. (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/virtualenv.py 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 https://bitbucket.org/akruis/slp-installer/downloads/stackless_installer_C4_linux_x86_64-
    Downloading/unpacking https://bitbucket.org/akruis/slp-installer/downloads/stackless_installer_C4_linux_x86_64-
      Downloading stackless_installer_C4_linux_x86_64- (2.3MB): 2.3MB downloaded
      Running setup.py egg_info for package from https://bitbucket.org/akruis/slp-installer/downloads/stackless_installer_C4_linux_x86_64-
    Installing collected packages: stackless-installer-C4-linux-x86-64
      Running setup.py 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/libpython2.7.so.1.0sl
    creating /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/copy_reg.py -> /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/__init__.py -> /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/__init__.py -> /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/build_ext.py -> /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/platform.py -> /tmp/test/lib64/python2.7/stackless-packages
    copying /tmp/test/lib/python2.7/site-packages/slpInstaller/Lib/pickle.py -> /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/stackless.py -> /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/copy_reg.py to copy_reg.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/platform.py to platform.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/pickle.py to pickle.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/stackless.py to stackless.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/distutils/__init__.py to __init__.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/distutils/command/__init__.py to __init__.pyc
    byte-compiling /tmp/test/lib64/python2.7/stackless-packages/distutils/command/build_ext.py 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 libpython2.7.so.1.0sl is compatible with the existing 2.7.0 installation.

    Regards Anselm

    Am 16.07.2014 14:51, schrieb Michael Bravo:

  2. 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

  3. 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?

  4. Log in to comment