Giter Site home page Giter Site logo

Comments (22)

yangmeishu avatar yangmeishu commented on August 17, 2024 327

resolve : sudo apt-get install python3-distutils

from get-pip.

0xmjk avatar 0xmjk commented on August 17, 2024 11

@nirorman I had the same issue with 3.7 as well.

I hacked around it like this:

apt-get download python3-distutils
dpkg-deb -x python3-distutils /
curl https://bootstrap.pypa.io/get-pip.py | python3.7

What it does is that it downloads the package with apt-get without installing. Then dpkg-deb extracts it outside of apt/dpkg processes to / (whilst ignoring dependencies).

Why it works is that the python3-distutils package (at least in its current state) provides for both Python versions - 3.6 and 3.7. However, it also pulls all python3 packages, whereas I wanted only python3.7 packages.

Hope it helps!

from get-pip.

pradyunsg avatar pradyunsg commented on August 17, 2024 8

For clarity for folks dealing with this, this occurs because someone over on the Debian side decided to actively exclude distutils from the default python.

We've flagged this to the Debian folks before and it's not an issue that pip can do much about.

from get-pip.

pradyunsg avatar pradyunsg commented on August 17, 2024 7

I'm going to go ahead and summarize this issue one last time.

For users facing this issue on Ubuntu (or anything else Debian based), this occurs because Debian decided that distutils is not a "core Python" package, despite being a part of the Python standard library. All of Python Packaging tooling is written to assume that distutils is available.

The way to fix this would be to run:

$ sudo apt-get install python3-distutils

from get-pip.

rachmadaniHaryono avatar rachmadaniHaryono commented on August 17, 2024 7

i get here from because this is first search result for my error

this happen on my python3.7 installation but not my main python3 after i upgrade my ubuntu to 20.04

~ python3 --version
Python 3.6.10
➜  ~ python3.7 -m pip --version
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/q/.local/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/home/q/.local/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/q/.local/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/q/.local/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/q/.local/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
  • solution 1: install python3-distutils

it is already installed and reinstall it change nothing

  • solution 2: download python3-distutils deb, install deb, download get-pip & run python3 get-pip

it failed when run i python3 on script

~ curl https://bootstrap.pypa.io/get-pip.py | python3.7
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1824k  100 1824k    0     0   264k      0  0:00:06  0:00:06 --:--:--  358k
Traceback (most recent call last):
  File "<stdin>", line 23470, in <module>
  File "<stdin>", line 198, in main
  File "<stdin>", line 82, in bootstrap
  File "/tmp/tmpct3zaj9_/pip.zip/pip/_internal/cli/main.py", line 10, in <module>
  File "/tmp/tmpct3zaj9_/pip.zip/pip/_internal/cli/autocompletion.py", line 9, in <module>
  File "/tmp/tmpct3zaj9_/pip.zip/pip/_internal/cli/main_parser.py", line 7, in <module>
  File "/tmp/tmpct3zaj9_/pip.zip/pip/_internal/cli/cmdoptions.py", line 19, in <module>
ModuleNotFoundError: No module named 'distutils.util'

what working for me:

from get-pip.

eskp avatar eskp commented on August 17, 2024 6

This makes it impossible to install pip3 as non root user as installing of python3-distutils requires root privs.

from get-pip.

nirorman avatar nirorman commented on August 17, 2024 3

the same issue
os:wsl ubuntu 1804
version:3.7

from get-pip.

mradulovic988 avatar mradulovic988 commented on August 17, 2024 2

The same issue on PyCharm and Ubuntu 20.

This is the fix: sudo apt-get install python3-distutils

from get-pip.

adamdry avatar adamdry commented on August 17, 2024 1

Thanks, I also had to do this sudo apt install python3-testresources and run the script with sudo sudo python3 get-pip.py

from get-pip.

HemilTheRebel avatar HemilTheRebel commented on August 17, 2024 1

TLDR; Removing virtualenv directory and acitivating a new virtual env worked

I had this issue. One fine day, pip decided to want to make me die cause it was working perfectly just the day before. None of the above solutions worked for me. Then I went old school and deleted the venv and activated a new one and installed the dependencies of my project and it worked perfectly

from get-pip.

yangmeishu avatar yangmeishu commented on August 17, 2024

the same issue
os:wsl ubuntu 1804
version:3.6.7

from get-pip.

shankarprabhakaran9 avatar shankarprabhakaran9 commented on August 17, 2024

pi@raspberrypi:~ $ sudo python3 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 21492, in
main()
File "get-pip.py", line 197, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip._internal
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/init.py", line 40, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/cli/autocompletion.py", line 8, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/cli/main_parser.py", line 12, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/commands/init.py", line 6, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/commands/completion.py", line 6, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/cli/base_command.py", line 20, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/download.py", line 26, in
File "", line 1032, in _handle_fromlist
File "/tmp/tmps2sh7lpy/pip.zip/pip/_vendor/six.py", line 92, in get
result = self._resolve()
File "/tmp/tmps2sh7lpy/pip.zip/pip/_vendor/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/tmp/tmps2sh7lpy/pip.zip/pip/_vendor/six.py", line 82, in _import_module
import(name)
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 724, in exec_module
File "", line 857, in get_code
File "", line 525, in _compile_bytecode
ValueError: bad marshal data (invalid reference)

from get-pip.

shankarprabhakaran9 avatar shankarprabhakaran9 commented on August 17, 2024

i am getting error if i do pip install python3

pi@raspberrypi:~ $ sudo python3 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 21492, in
main()
File "get-pip.py", line 197, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip._internal
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/init.py", line 40, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/cli/autocompletion.py", line 8, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/cli/main_parser.py", line 12, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/commands/init.py", line 6, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/commands/completion.py", line 6, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/cli/base_command.py", line 20, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 668, in _load_unlocked
File "", line 638, in _load_backward_compatible
File "/tmp/tmps2sh7lpy/pip.zip/pip/_internal/download.py", line 26, in
File "", line 1032, in _handle_fromlist
File "/tmp/tmps2sh7lpy/pip.zip/pip/_vendor/six.py", line 92, in get
result = self._resolve()
File "/tmp/tmps2sh7lpy/pip.zip/pip/_vendor/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/tmp/tmps2sh7lpy/pip.zip/pip/_vendor/six.py", line 82, in _import_module
import(name)
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 724, in exec_module
File "", line 857, in get_code
File "", line 525, in _compile_bytecode
ValueError: bad marshal data (invalid reference)

from get-pip.

jonseymour avatar jonseymour commented on August 17, 2024

@nirorman I had the same issue with 3.7 as well.

I hacked around it like this:

apt-get download python3-distutils
dpkg-deb -x python3-distutils /
curl https://bootstrap.pypa.io/get-pip.py | python3.7

What it does is that it downloads the package with apt-get without installing. Then dpkg-deb extracts it outside of apt/dpkg processes to / (whilst ignoring dependencies).

Why it works is that the python3-distutils package (at least in its current state) provides for both Python versions - 3.6 and 3.7. However, it also pulls all python3 packages, whereas I wanted only python3.7 packages.

Hope it helps!

@0xmjk

This mostly worked for me, thank you.

I did have to make sure I ran the extract in a directory that the _apt user could read (I chose /tmp) and I needed to specify the full file name of the python3-distutils.deb, but other than that it worked well, so thank you.

from get-pip.

pradyunsg avatar pradyunsg commented on August 17, 2024

You shouldn't sudo python get-pip.py, that'll mangle files managed by your operating system installer.

from get-pip.

Law101 avatar Law101 commented on August 17, 2024

resolve : sudo apt-get install python3-distutils

Thank you!

from get-pip.

moxy-bc avatar moxy-bc commented on August 17, 2024

I have installed python3-distutils on Python 3.7, but now I get this:

pi@rpi3b:~/opencv/projects $ pip freeze
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/commands/init.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/commands/freeze.py", line 8, in
from pip._internal.cache import WheelCache
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cache.py", line 8, in
import json
File "/usr/lib/python3.7/json/init.py", line 106, in
from .decoder import JSONDecoder, JSONDecodeError
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 724, in exec_module
File "", line 857, in get_code
File "", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)

from get-pip.

chrahunt avatar chrahunt commented on August 17, 2024

Hi @moxy-bc, it looks like your Python installation may be the problem since the actual exception is raised outside of pip's code and does not depend on any input that pip provides. I would try searching and posting on stackoverflow, that should get your issue better exposure.

from get-pip.

pradyunsg avatar pradyunsg commented on August 17, 2024

For folks facing issue with the marshal bug, please file a new issue here.

from get-pip.

engelmav avatar engelmav commented on August 17, 2024

Downgrading distutils worked for me.

from get-pip.

imSunnyk avatar imSunnyk commented on August 17, 2024

Thanks, I also had to do this sudo apt install python3-testresources and run the script with sudo sudo python3 get-pip.py

Thank you ....it worked for me

from get-pip.

ahaghgoo avatar ahaghgoo commented on August 17, 2024

what would be the command to install on QNAP?

from get-pip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.