Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setuptools-34.0 fails with 'ImportError: No module named packaging.version' #937

Closed
jhmartin opened this issue Jan 23, 2017 · 38 comments
Closed

Comments

@jhmartin
Copy link

jhmartin commented Jan 23, 2017

Upgrading to setuptools-34.0 fails with ImportError: No module named packaging.version:

pip --version
pip 1.4.1 from /usr/lib/python2.6/site-packages (python 2.6)
---- Begin output of /usr/bin/pip install  --upgrade setuptools ----
STDOUT: Downloading/unpacking setuptools from https://pypi.python.org/packages/4f/5d/77ab299135d7a882fff2970b45c6a77d7d79db0363c395081770632e6f1d/setuptools-34.0.0.zip#md5=927ea526582deefbf98779b2c302dd3d
  Running setup.py egg_info for package setuptools
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "setuptools/__init__.py", line 12, in <module>
        import setuptools.version
      File "setuptools/version.py", line 1, in <module>
        import pkg_resources
      File "pkg_resources/__init__.py", line 70, in <module>
        import packaging.version
    ImportError: No module named packaging.version
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "setuptools/__init__.py", line 12, in <module>

    import setuptools.version

  File "setuptools/version.py", line 1, in <module>

    import pkg_resources

  File "pkg_resources/__init__.py", line 70, in <module>

    import packaging.version

ImportError: No module named packaging.version

CentOS 6 in AWS.

@patroqueeet
Copy link

+1 under ubuntu14.04

@jhmartin
Copy link
Author

Upgrading PIP seems to have fixed it:

pip --version
pip 9.0.1 from /usr/lib/python2.6/site-packages (python 2.6)

@jaraco
Copy link
Member

jaraco commented Jan 23, 2017

Indeed. This outcome is expected. In particular, it's at this line where things go wrong:

Running setup.py egg_info for package setuptools

That's pip asking setuptools to build itself (from source dist), which is no longer supported.

The reason that happened on an old pip is because that pip version didn't yet support installation from wheels, which bypasses the unsupported installation.

If you had wanted to install from sdist, you would have to manually install packaging, appdirs, and six first.

@patroqueeet
Copy link

still, something seems wrong to me when I'm blindly running into this. without warning, dependency fail or similar. I think it might be good for users to be aware and informed about the need to upgrade to latest pip as a dependency for v34

@realmhamdy
Copy link

realmhamdy commented Jan 25, 2017

I'm unable to pip anything now because of this error. It occurred when I updated my Ubuntu trusty:
Not pip --version

vagrant@vagrant-ubuntu-trusty-32:~/$ pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named packaging.version

And of course not pip install:

vagrant@vagrant-ubuntu-trusty-32:~/$ pip install packaging
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named packaging.version

easy_install doesn't work either with the same error. what should I do?

@lambda-conjecture
Copy link

Just ran into this - fixed pip by re-installing pip via the get-pip.py method described here: https://packaging.python.org/installing/#install-pip-setuptools-and-wheel

@jaraco
Copy link
Member

jaraco commented Jan 25, 2017

I'm unable to pip anything now

You can reinstall pip using get-pip.py as @lambda-conjecture suggested. You may also be able to reinstall it with python -m pip install -U pip.

opnfv-github pushed a commit to opnfv/storperf that referenced this issue Jan 26, 2017
Forces explicit version of setuptools to be used because
of an upstream change:
pypa/setuptools#937

Change-Id: I4124dedee38713ca1bfa445944d8d79cf1be6c15
JIRA: STORPERF-102
Signed-off-by: mbeierl <mark.beierl@dell.com>
@rampageservices
Copy link

@davidavdav
Copy link

@rampageservices referenced method worked for me, for a clean debian-8 (jessie) install in a Vagrant VM. For those like me at python2.7:

sudo -i
apt-get purge -y python-pip
wget https://bootstrap.pypa.io/get-pip.py
python ./get-pip.py
apt-get install python-pip

It was the only one of all suggestions I could find that actually did the job. Thanks!

@segatecm
Copy link

segatecm commented Feb 10, 2017

reinstall get-pip.py can not work to my debian jessie

python ./get-pip.py report error!
Exception:

Traceback (most recent call last):
  File "/tmp/tmpl9axz8dk/pip.zip/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/tmp/tmpl9axz8dk/pip.zip/pip/commands/install.py", line 272, in run
    with self._build_session(options) as session:
  File "/tmp/tmpl9axz8dk/pip.zip/pip/basecommand.py", line 72, in _build_session
    insecure_hosts=options.trusted_hosts,
  File "/tmp/tmpl9axz8dk/pip.zip/pip/download.py", line 329, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/tmp/tmpl9axz8dk/pip.zip/pip/download.py", line 93, in user_agent
    from pip._vendor import distro
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/tmp/tmpl9axz8dk/pip.zip/pip/_vendor/distro.py", line 1050, in <module>
    _distro = LinuxDistribution()
  File "/tmp/tmpl9axz8dk/pip.zip/pip/_vendor/distro.py", line 594, in __init__
    if include_lsb else {}
  File "/tmp/tmpl9axz8dk/pip.zip/pip/_vendor/distro.py", line 933, in _get_lsb_release_info
    raise subprocess.CalledProcessError(code, cmd, stdout)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
Traceback (most recent call last):
  File "get-pip.py", line 20061, in <module>
    main()
  File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 172, in bootstrap
    sys.exit(pip.main(["install", "--upgrade"] + args))
  File "/tmp/tmpl9axz8dk/pip.zip/pip/__init__.py", line 233, in main
  File "/tmp/tmpl9axz8dk/pip.zip/pip/basecommand.py", line 251, in main
  File "/tmp/tmpl9axz8dk/pip.zip/pip/basecommand.py", line 72, in _build_session
  File "/tmp/tmpl9axz8dk/pip.zip/pip/download.py", line 329, in __init__
  File "/tmp/tmpl9axz8dk/pip.zip/pip/download.py", line 93, in user_agent
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/tmp/tmpl9axz8dk/pip.zip/pip/_vendor/distro.py", line 1050, in <module>
  File "/tmp/tmpl9axz8dk/pip.zip/pip/_vendor/distro.py", line 594, in __init__
  File "/tmp/tmpl9axz8dk/pip.zip/pip/_vendor/distro.py", line 933, in _get_lsb_release_info
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1

so, it make me cry!

@jaraco
Copy link
Member

jaraco commented Feb 10, 2017

@segatecm: Python is complaining that lsb_release -a is failing. What do you get if you run that command by itself?

@venkataGoli
Copy link

I had the same same issue when I was trying to do a
sudo pip install cryptography

Error Message:

Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/usr/local/lib/python2.7/dist-packages/setuptools/init.py", line 12, in
import setuptools.version
File "/usr/local/lib/python2.7/dist-packages/setuptools/version.py", line 1, in
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 70, in
import packaging.version
ImportError: No module named packaging.version

Running
sudo pip install -U setuptools
and then
sudo pip install cryptography
solved my issue.

Hope this helps !

@mhumzawan
Copy link

I am having same issues, I have tried everything from redeploying and installing correct library versions. Still I am not able to resolve the issue.

"{u'message': u'An uncaught exception happened while servicing this request. You can investigate this with the zappa tail command.', u'traceback': ['Traceback (most recent call last):\n', ' File "/var/task/handler.py", line 434, in handler\n response = Response.from_app(self.wsgi_app, environ)\n', ' File "c:\\users\\dell\\appdata\\local\\temp\\pip-build-hhbeih\\Werkzeug\\werkzeug\\wrappers.py", line 903, in from_app\n', ' File "c:\\users\\dell\\appdata\\local\\temp\\pip-build-hhbeih\\Werkzeug\\werkzeug\\wrappers.py", line 57, in _run_wsgi_app\n', ' File "c:\\users\\dell\\appdata\\local\\temp\\pip-build-hhbeih\\Werkzeug\\werkzeug\\test.py", line 884, in run_wsgi_app\n', "TypeError: 'NoneType' object is not callable\n"]}"

I think issue is with WerkZeug.

Can anyone help me out?

@aarcro
Copy link

aarcro commented Aug 30, 2017

@mhumzawan Check your zappa logs, the real exception happens before that WerkZeug error. Only once on the first call to the lambda after deployment.

@ghost
Copy link

ghost commented Jan 28, 2018

I had installed pip via easy_install,
easy_install -U pip
now I used
python -m pip install -U pip

This reinstalled pip and somehow the dependency on setuptools got fixed!

@ghost
Copy link

ghost commented May 15, 2018

(tensorflow) C:\Users\Lenovo\Desktop\CoopNets-master\CoopNets-master>python main.py --category alp --data_dir ./data/scene --output_dir ./output --num_epochs 300 --batch_size 100 --d_lr 0.01 --g_lr 0.0001
Traceback (most recent call last):
File "main.py", line 85, in
tf.app.run()
File "C:\Users\Lenovo\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
_sys.exit(main(argv))
File "main.py", line 71, in main
tf.gfile.MakeDirs(log_dir)
File "C:\Users\Lenovo\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 374, in recursive_create_dir
pywrap_tensorflow.RecursivelyCreateDir(compat.as_bytes(dname), status)
File "C:\Users\Lenovo\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 519, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a directory: ./output\alp\log; No such file or directory

what to do at this time...plz reply fast..

twaugh added a commit to containerbuildsystem/osbs-client that referenced this issue May 22, 2018
See pypa/setuptools#937

Signed-off-by: Tim Waugh <twaugh@redhat.com>
twaugh added a commit to containerbuildsystem/koji-containerbuild that referenced this issue May 22, 2018
See pypa/setuptools#937

Signed-off-by: Tim Waugh <twaugh@redhat.com>
mlangsdorf pushed a commit to containerbuildsystem/osbs-client that referenced this issue May 22, 2018
See pypa/setuptools#937

Signed-off-by: Tim Waugh <twaugh@redhat.com>
twaugh added a commit to containerbuildsystem/dockerfile-parse that referenced this issue May 31, 2018
See pypa/setuptools#937

Signed-off-by: Tim Waugh <twaugh@redhat.com>
lcarva pushed a commit to containerbuildsystem/dockerfile-parse that referenced this issue May 31, 2018
See pypa/setuptools#937

Signed-off-by: Tim Waugh <twaugh@redhat.com>
@tobsecret
Copy link

Just commenting on here for folks that are having this issue with newer versions of setuptools on conda. What fixed this for me was conda install packaging. I don't know why the other top-results on google did not work for me, but this did the trick.

ben-alkov added a commit to ben-alkov/koji-containerbuild that referenced this issue Jun 1, 2020
...to guard against deprecation failures.
pip and setuptools are smart enough to work
out version compatibility for the current os/Py.

Also bypasses ancient pypa/setuptools#937
ben-alkov added a commit to ben-alkov/koji-containerbuild that referenced this issue Jun 1, 2020
...to guard against deprecation failures.
pip and setuptools are smart enough to work
out version compatibility for the current os/Py.

Also bypasses ancient pypa/setuptools#937
ben-alkov added a commit to ben-alkov/koji-containerbuild that referenced this issue Jun 1, 2020
...to guard against deprecation failures.
pip and setuptools are smart enough to work
out version compatibility for the current os/Py.

Also bypasses ancient pypa/setuptools#937

Signed-off-by: Ben Alkov <ben.alkov@redhat.com>
ben-alkov added a commit to ben-alkov/koji-containerbuild that referenced this issue Jun 1, 2020
...to guard against deprecation failures.
pip and setuptools are smart enough to work
out version compatibility for the current os/Py.

Also bypasses ancient pypa/setuptools#937

Signed-off-by: Ben Alkov <ben.alkov@redhat.com>
@sravano9
Copy link

sravano9 commented Oct 1, 2020

Hi All,

When I am running RUN pip install -U setuptools inside docker file facing

---> Running in f1588f1aeeec
Downloading/unpacking setuptools from https://files.pythonhosted.org/packages/7c/1b/9b68465658cda69f33c31c4dbd511ac5648835680ea8de87ce05c81f95bf/setuptools-50.3.0.zip#sha256=39060a59d91cf5cf403fa3bacbb52df4205a8c3585e0b9ba4b30e0e19d4c4b18
Running setup.py (path:/tmp/pip_build_root/setuptools/setup.py) egg_info for package setuptools
Traceback (most recent call last):
File "", line 3, in
File "setuptools/init.py", line 16, in
import setuptools.version
File "setuptools/version.py", line 1, in
import pkg_resources
File "pkg_resources/init.py", line 1365
raise SyntaxError(e) from e
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 3, in

File "setuptools/init.py", line 16, in

import setuptools.version

File "setuptools/version.py", line 1, in

import pkg_resources

File "pkg_resources/init.py", line 1365

raise SyntaxError(e) from e

                        ^

SyntaxError: invalid syntax


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/setuptools
Storing debug log for failure in /home/.pip/pip.log
The command '/bin/sh -c pip install -U setuptools' returned a non-zero code: 1

what can be the fix for this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests