pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.51k stars 3.02k forks source link

Exception "IndexError: list index out of range" & ImportError: cannot import name main #6454

Closed slrslr closed 5 years ago

slrslr commented 5 years ago

Environment

pip install gevent --upgrade

Collecting gevent
  Downloading https://files.pythonhosted.org/packages/ed/27/6c49b70808f569b66ec7fac2e78f076e9b204db9cf5768740cff3d5a07ae/gevent-1.4.0.tar.gz (5.2MB)
    100% |████████████████████████████████| 5.2MB 31kB/s
Collecting greenlet>=0.4.14; platform_python_implementation == "CPython" (from gevent)
  Downloading https://files.pythonhosted.org/packages/f8/e8/b30ae23b45f69aa3f024b46064c0ac8e5fcb4f22ace0dca8d6f9c8bbe5e7/greenlet-0.4.15.tar.gz (59kB)
    100% |████████████████████████████████| 61kB 1.2MB/s
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 328, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 748, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 448, in _prepare_file
    req_to_install, finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 387, in _check_skip_installed
    req_to_install.check_if_exists()
  File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 997, in check_if_exists
    self.satisfied_by = pkg_resources.get_distribution(self.req)
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 535, in get_distribution
    dist = get_provider(dist)
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 415, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
IndexError: list index out of range
You are using pip version 8.1.1, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

pip install --upgrade pip

  Downloading https://files.pythonhosted.org/packages/f9/fb/863012b13912709c13cf5cfdbfb304fa6c727659d6290438e1a88df9d848/pip-19.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 117kB/s
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-19.1

pip install gevent --upgrade

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

Please how can i install gevent & msgpack-python without error?

UPDATE: after i installed several linux tools, the ImportError no longer appeared. It installed some python components and then after that i see the pip install commands worked:

pip install gevent --upgrade

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting gevent
  Using cached https://files.pythonhosted.org/packages/ed/27/6c49b70808f569b66ec7fac2e78f076e9b204db9cf5768740cff3d5a07ae/gevent-1.4.0.tar.gz
  Ignoring cffi: markers 'sys_platform == "win32" and platform_python_implementation == "CPython"' don't match your environment
Collecting greenlet>=0.4.14; platform_python_implementation == "CPython" (from gevent)
  Using cached https://files.pythonhosted.org/packages/f8/e8/b30ae23b45f69aa3f024b46064c0ac8e5fcb4f22ace0dca8d6f9c8bbe5e7/greenlet-0.4.15.tar.gz
Building wheels for collected packages: gevent, greenlet
  Building wheel for gevent (setup.py) ... done
  Stored in directory: /root/.cache/pip/wheels/35/a6/a0/c8441dbd28276aaff148c417279dee46f84936ba108cf32208
  Building wheel for greenlet (setup.py) ... done
  Stored in directory: /root/.cache/pip/wheels/cc/28/5a/2687513046a61b17dd78be058a43a069c271f5d7b7623f3dfd
Successfully built gevent greenlet
ERROR: gevent 1.4.0 requires cffi>=1.11.5, which is not installed.
Installing collected packages: greenlet, gevent
Successfully installed gevent-1.4.0 greenlet-0.4.15

Python script i am running says: The 'cffi>=1.11.5' distribution was not found and is required by the application

so i ran: pip install cffi

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

Can anyone please share what was missing component when i got first error and how to fix last error with cffi ?

After "reboot" it started doing something:

pip install cffi
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting cffi
  Downloading https://files.pythonhosted.org/packages/93/1a/ab8c62b5838722f29f3daffcc8d4bd61844aa9b5f437341cc890ceee483b/cffi-1.12.3.tar.gz (456kB)
     |████████████████████████████████| 460kB 2.7MB/s
Collecting pycparser (from cffi)
  Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB)
     |████████████████████████████████| 163kB 5.6MB/s
Building wheels for collected packages: cffi, pycparser
  Building wheel for cffi (setup.py) ... error
  ERROR: Complete output from command /usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1buQoi/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ihs3Xm --python-tag cp27:
  ERROR: running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-2.7
  creating build/lib.linux-armv7l-2.7/cffi
  copying cffi/cparser.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/vengine_gen.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/model.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/recompiler.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/api.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/lock.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/pkgconfig.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/commontypes.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/error.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/ffiplatform.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/__init__.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/verifier.py -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/_cffi_include.h -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/parse_c_type.h -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/_embedding.h -> build/lib.linux-armv7l-2.7/cffi
  copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-2.7/cffi
  running build_ext
  building '_cffi_backend' extension
  creating build/temp.linux-armv7l-2.7
  creating build/temp.linux-armv7l-2.7/c
  arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
  c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
  compilation terminated.
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for cffi
  Running setup.py clean for cffi
  Building wheel for pycparser (setup.py) ... done
  Stored in directory: /root/.cache/pip/wheels/f2/9a/90/de94f8556265ddc9d9c8b271b0f63e57b26fb1d67a45564511
Successfully built pycparser
Failed to build cffi
Installing collected packages: pycparser, cffi
  Running setup.py install for cffi ... error
    ERROR: Complete output from command /usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1buQoi/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-INpuRP/install-record.txt --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-2.7
    creating build/lib.linux-armv7l-2.7/cffi
    copying cffi/cparser.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/model.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/recompiler.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/api.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/lock.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/commontypes.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/error.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/__init__.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/verifier.py -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/_embedding.h -> build/lib.linux-armv7l-2.7/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-2.7/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-armv7l-2.7
    creating build/temp.linux-armv7l-2.7/c
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
    compilation terminated.
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1buQoi/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-INpuRP/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-1buQoi/cffi/
chrahunt commented 5 years ago

Hello. Are you still having issues? I think that these problems would be helped by checking out #5599 for the issue related to pip update (essentially: use your system's package manager to update pip), and #4861 if there are still issues with ffi.h (though I see some progress was made on this in HelloZeroNet/ZeroNet#2002).

chrahunt commented 5 years ago

Hi @slrslr. I'll close this issue now, but please let us know if you have any other problems.