Comments (22)
resolve : sudo apt-get install python3-distutils
from get-pip.
@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.
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.
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.
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:
- add deadsnake ppa https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
- install python3.7
from get-pip.
This makes it impossible to install pip3 as non root user as installing of python3-distutils requires root privs.
from get-pip.
the same issue
os:wsl ubuntu 1804
version:3.7
from get-pip.
The same issue on PyCharm and Ubuntu 20.
This is the fix: sudo apt-get install python3-distutils
from get-pip.
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.
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.
the same issue
os:wsl ubuntu 1804
version:3.6.7
from get-pip.
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.
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.
@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!
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.
You shouldn't sudo python get-pip.py, that'll mangle files managed by your operating system installer.
from get-pip.
resolve : sudo apt-get install python3-distutils
Thank you!
from get-pip.
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.
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.
For folks facing issue with the marshal bug, please file a new issue here.
from get-pip.
Downgrading distutils worked for me.
from get-pip.
Thanks, I also had to do this
sudo apt install python3-testresources
and run the script with sudosudo python3 get-pip.py
Thank you ....it worked for me
from get-pip.
what would be the command to install on QNAP?
from get-pip.
Related Issues (20)
- {install,build,which} response HOT 1
- Python versions being tested by CI don't match noxfile HOT 3
- error while running command get-pip.py --no-setuptools HOT 1
- Having difficulty installing and opening PIP in my windows 10 command prompt HOT 1
- remove this? HOT 1
- boostrap.pypa's SSL certificate has expired HOT 4
- ModuleNotFoundError: No module named 'distutils.cmd' HOT 2
- Cx Freeze custom package in project, import error.
- 3.2 installation pip<8 requirements
- Versionned zipapps not available HOT 5
- nox -s generate gives the error "AttributeError: 'HTTPResponse' object has no attribute 'strict'" HOT 2
- Number error HOT 1
- externally-managed-environment HOT 1
- Stop installing setuptools and wheel by default HOT 4
- not all python version could be found in bootstrap.pypa.io/pip HOT 1
- Validating the authenticity of get-pip.py HOT 1
- Error While trying to use pip , pip3 .
- get-pip.py script not compatible with Python 3.7 HOT 4
- [question] Why not keep the raw binary data within get-pip.py?
- [bug] pip not working on python embeddable package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from get-pip.