3

Here's what I get when I try to install sqalchemy

Traceback (most recent call last):
  File "/usr/bin/easy_install", line 11, in <module>
    load_entry_point('setuptools==33.1.1', 'console_scripts', 'easy_install')()
  File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 572, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
    return ep.load()
  File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2408, in load
    return self.resolve()
  File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2414, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 51, in <module>
    from setuptools.archive_util import unpack_archive
  File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 12, in <module>
    from pkg_resources import ContextualZipFile
ImportError: cannot import name ContextualZipFile

I have tried installing and uninstalling setuptools.

I have also tried changing "from pkg_resources import ensure_directory, ContextualZipFile" to "from pkg_resources import ensure_directory" in my usr/local/lib/python2.7/dist-packages/setuptools/archive_util.py. However I get the error

Best match: MySQL-python 1.2.5
Processing MySQL-python-1.2.5.zip
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 11, in <module>
    load_entry_point('setuptools==33.1.1', 'console_scripts', 'easy_install')()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2325, in main
    **kw
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 436, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 699, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 725, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 876, in install_eggs
    unpack_archive(dist_filename, tmpdir, self.unpack_progress)
  File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 53, in unpack_archive
    driver(filename, extract_dir, progress_filter)
  File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 102, in unpack_zipfile
    with ContextualZipFile(filename) as z:
NameError: global name 'ContextualZipFile' is not defined

I have also tried directly importing pkg_resources but it still can't find ContextualZipFile. I get the error:

NameError: global name 'ContextualZipFile' is not defined

I use python version = 2.7.13 and pip version = 9.0.1

I am also doing this inside a virtualenvironment

2 Answers 2

2

This is a pretty nasty hack but I just commented out the import and easy_install seems to be working fine. Change the corresponding line to:

from pkg_resources import ensure_directory#, ContextualZipFile

NOTE: It's a system file so you're gonna have to use sudo privilege to change it. You can do that using: sudo vim filename.

It's not a great fix, but if you need to get it working in a hurry, this should do the trick. Hope this helps!

0

This seems like a common bug https://github.com/pypa/setuptools/issues/252

Easiest way is to use an alternative, like: yum -y install python-pip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.