Environment
CircleCI using Conda, eg https://circleci.com/gh/peterjc/thapbi-pict/1073
pip install --upgrade pip setuptools
)I have made only minor changes to my code, but today the CircleCI builds broke during the build/install stage of my Python tool - multiple branches affected. The timing fits the release of pip 19.3 on PyPI.
Description
It appears a recent release of pip moved some internal files about, my guess is #6830.
Expected behavior
How to Reproduce
Full output on https://circleci.com/gh/peterjc/thapbi-pict/1073 which is running https://github.com/peterjc/thapbi-pict/blob/9fcec2da60e6e6ae5cf7ee6ad4b53dcc3a40cfe7/.circleci/config.yml#L56
...
python setup.py sdist --formats=gztar
python setup.py bdist_wheel
pip install dist/thapbi_pict-*.whl
Output
Traceback (most recent call last):
File "/opt/conda/bin/pip", line 7, in <module>
from pip._internal import main
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 11, in <module>
from pip._internal.commands import (
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 9, in <module>
from pip._internal.commands.download import DownloadCommand
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/commands/download.py", line 10, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 9, in <module>
from pip._internal.distributions import (
File "/opt/conda/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/opt/conda/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)
Exited with code 1
It would be really helpful to know what in the CircleCI (or conda?) setup is using those internal APIs - the reorganisation shouldn't have affected any external code. The main issue we know of so far is the reorganisation of main, which impacts wrapper scripts, but this one looks a bit different. Any insight you can give would be very useful, thanks.
Confirmed that removing pip install --upgrade pip setuptools
fixed things,
https://github.com/peterjc/thapbi-pict/commit/4060404c1034a676439aef1369260022577a6627
https://circleci.com/gh/peterjc/thapbi-pict/1074
i.e. Something broke in how I updated from pip 19.2.3 to 19.3
I am not intentionally using the CircleCI provided Python, rather the Conda provided Python - is there value in switching from pip ...
to python -m pip ...
just to remove the possibility of this being due to mixing Pythons?
Working on a branch now, added a little more logging and reverted back to the broken version:
https://circleci.com/gh/peterjc/thapbi-pict/1076
This confirms the traceback is trigged by pip install dist/thapbi_pict-*.whl
(wildcard to match the single freshly built wheel).
OK, using python -m pip ...
rather than pip ...
does not help:
https://circleci.com/gh/peterjc/thapbi-pict/1077
https://github.com/peterjc/thapbi-pict/commit/c168fbb7b61b2670bfb73dfb7ea87605fd17bfaf
For what it's worth, I've just confirmed that from pip._internal import main
works on a simple upgrade of pip (on Windows, so not really a good comparison, but anyway...). So I suspect there's something mismatched in your environment, although I can't see from the traceback what it is.
CircleCI has the capability to re-run a job with SSH access to the VM (not that I've ever used it), so in theory this could be used for debugging, but I don't really know where to start.
I have a work around for now, and at some point conda-forge will have pip 19.3 packaged too, so unless other people see the same exception, it seems a low priority?
OK, cool. If you have a workaround then I'm fine leaving it there for now. If others add comments reporting it's happening elsewhere, we can do some more digging then - maybe they will have extra information that will help.
I am facing a similar issue on macOS, python: 3.6.9. pip command on my terminal doesn't work anymore. Any suggestions?
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
This helped for now
I have same problem on CircleCI since 1 hours ago.
Version changing of docker image from python:3.7 to python:3.7.4 fixes this issue. (just workaround) . like this:
version: 2
...
jobs:
build:
docker:
- image: python:3.7.4
...
Are any of you guys using caching? I think it's possible some pip internals changed and when you restore the cache of the old python version pip breaks. Suggest you invalidate your circle CI caches by changing the keys
and see what happens ... (worked for me!)
As suggested by @bgkelly clearing the cache also worked for me!
Yep - same for me - changing the cache key has solved this for our team's projects on circleci. Thanks @bgkelly
Changing the cache key did not solve it for me.
Adding a comment in requirements.txt
did it though, but that's not a desired solution.
Alright, so this seems like a caching issue for CircleCI.
Could someone please reach out to CircleCI folks (via their support channels)? It'd be great if they could look into this and possibly chime in here.
Hey people,
I really don't know if this helps you in any way, but I got the same Error Message on my MSYS setup trying to install WeasyPrint.
After uninstalling python3-pip and python3-setuptools i deleted all pip folders in /usr/lib/python3.7/site-packages/ and reinstalled both.. solved that specific error.
pacman -R python3-pip python3-setuptools
rm -R /usr/lib/python3.7/site-packages/pip
rm -R /usr/lib/python3.7/site-packages/pip-19.3.1.dist-info
pacman -S python3-pip python3-setuptools
To be fair, I now ran into compiler issues... but maybe i could help....
Just in case this may help, I have encountered the error in a different context: when copying a virtual environment from one docker image to another, in a multistage setup.
The source image contains a less recent version of pip
whereas the target image contains an upgraded version of pip
. After copying the virtual environment directory of the source image into the target image, there are 2 different directories (pip-<version>.dist-info
) under the virtual environment site-packages
and pip
does not work, giving the same error as reported in this issue.
I did not spend time troubleshooting the issue as I am somewhat skeptical of this approach involving copying the virtual environment into an environment where there are already packages installed.
In any case, it appears to be a package collision problem.
Hope this helps! :smile:
Hi
I believe we see the same issue on our internal ReadTheDocs server. It runs the following command when building a document:
var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/bin/python -m pip install --upgrade --cache-dir /var/lib/readthedocs/repo/user_builds/some_doc/.cache/pip pip
If I clear the build cache via the ReadTheDocs GUI interface, the build is successful - but only until next time a build is started.
Here is the full log:
Traceback (most recent call last):
File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 11, in <module>
from pip._internal.commands import (
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 9, in <module>
from pip._internal.commands.download import DownloadCommand
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/commands/download.py", line 10, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 9, in <module>
from pip._internal.distributions import (
File "/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/lib/python3.6/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution'
Hi,
I've encountered the problem too.
OS: Debian GNU/Linux 10 (Linux 4.19.0-6-amd64)
pip: 19.3.1
conda: 4.7.12
Python:3.7.4
$ pip
Traceback (most recent call last):
File "/home/jiang/anaconda3/bin/pip", line 7, in
from pip._internal import main
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/__init__.py", line 40, in
from pip._internal.cli.autocompletion import autocomplete
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in
from pip._internal.cli.main_parser import create_main_parser
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 11, in
from pip._internal.commands import (
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 9, in
from pip._internal.commands.download import DownloadCommand
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/commands/download.py", line 10, in
from pip._internal.operations.prepare import RequirementPreparer
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 9, in
from pip._internal.distributions import (
File "/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/home/jiang/anaconda3/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)
We were able to do work-around on our local ReadTheDocs server by changing the build flow to specifically use pip version 19.2.3. Now ReadTheDocs runs the following build command - and we no longer have caching issue:
/var/lib/readthedocs/repo/user_builds/some_doc/envs/latest/bin/python -m pip install --upgrade --cache-dir /var/lib/readthedocs/repo/user_builds/some_doc/.cache/pip pip==19.2.3
More specifically, we updated the local python_environment.py file to use a specific pip version: https://github.com/readthedocs/readthedocs.org/blob/7212d6ff738b24a10fb0f4227d3fbdf69e5cab42/readthedocs/doc_builder/python_environments.py#L322
cmd = pip_install_cmd + ['pip']
changed to:
cmd = pip_install_cmd + ['pip==19.2.3']
I know my setup might be different than most but the issue on my end was due to the PIP sources/
directory in the virtual environment (most likely PIP caching issues or something). Let me explain:
When deleting the user_builds/project/envs/
directory for a project and rebuilding it works but only until you go to rebuild with the envs/
directory present again. I spent a ton of time debugging what the issue was and it turns out it was the user_builds/project/envs/
directory (or something inside) causing issues. So I did more testing to figure out that it was the user_builds/project/envs/latest/lib/python3.6/site-packages/pip/_internal/distributions/source/
directory specifically causing issues. I removed the user_builds/project/envs/latest/lib/python3.6/site-packages/pip/_internal/distributions/source/
directory, rebuilt, and everything was fine. I rebuilt again and it failed. I checked the user_builds/project/envs/latest/lib/python3.6/site-packages/pip/_internal/distributions/
directory again and saw that source/
was present. So I went to my global Python install and moved the /path/to/lib/python3.6/dist-packages/pip/_internal/distributions/source/
directory from PIP, removed the user_builds/project/envs/latest/lib/python3.6/site-packages/pip/_internal/distributions/source/
directory from the project environment, and rebuilt. This built successfully and didn't copy over the source/
folder, perfect. So now any time the docs build they build without errors. I hope this helps someone else.
Cheers.
Try this:
1.curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2.python get-pip.py
@Guru36
Tried that many many times with no success. You have to do this at the start anyways so this wouldn't help. Thanks anyways though.
Cheers.
Try this:
1.curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2.python get-pip.py
Thank you
I'm now getting issues with this on the 0.20 release.
Looking into this now folks. If someone could provide instructions for how to reproduce with pip 20.0, that'd be great!
I run into the same problem:
virtualenv venv
. venv/bin/activate
pip install sqlalchemy pymysql
results into
Traceback (most recent call last):
File "/tmp/test/venv/bin/pip", line 11, in <module>
sys.exit(main())
File "/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/tmp/test/venv/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
from pip._internal.distributions import (
File "/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/tmp/test/venv/lib/python3.8/site-packages/pip/_internal/distributions/source/__init__.py)
If someone could provide instructions for how to reproduce with pip 20.0,
In short, "try to use pip"! The results of trying to install scipy on a working virtual env, which already has scipy installed (i.e. I expect pip to do nothing):
(farmcat3) [danielevans@rml-dev06 farmcat]$ pip install pip==20.0
Looking in indexes: https://pypi.org/simple, http://phabricator.jbarisk.com:8080
Collecting pip==20.0
Downloading https://files.pythonhosted.org/packages/60/65/16487a7c4e0f95bb3fc89c2e377be331fd496b7a9b08fd3077de7f3ae2cf/pip-20.0-py2.py3-none-any.whl (1.5MB)
|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 1.5MB 1.7MB/s
Installing collected packages: pip
Found existing installation: pip 19.3.1
Uninstalling pip-19.3.1:
Successfully uninstalled pip-19.3.1
pipSuccessfully installed pip-20.0
(farmcat3) [danielevans@rml-dev06 farmcat]$ pip install scipy
Traceback (most recent call last):
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/bin/pip", line 8, in <module>
sys.exit(main())
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
from pip._internal.distributions import (
File "/home/jbanorthwest.co.uk/danielevans/venvs/farmcat3/lib/python3.6/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution'
The curl get-pip.py
trick didn't work for me, but I solved looking for differences between my venv and the "official code" installed system-wise. (I'm on a cluster, _so hic sunt leones_...)
--- /usr/lib/python2.7/site-packages/pip/_internal/distributions/__init__.py 2019-10-28 08:47:20.727522000 +0100
+++ /home/dummyuser/ml/lib/python3.6/site-packages/pip/_internal/distributions/__init__.py 2020-01-21 12:55:48.000000000 +0100
@@ -1,4 +1,4 @@
-from pip._internal.distributions.source.legacy import SourceDistribution
+from pip._internal.distributions.source import SourceDistribution
from pip._internal.distributions.wheel import WheelDistribution
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
Moving to python -m pip
helped in my situation. From https://github.com/ome/jenkins-library-recursivemerge/pull/4/files
Fails:
(cd build && curl -sfL ${buildInfraUrl} | tar -zxf -)
virtualenv build/venv && build/venv/bin/pip install ${sccPackage}
Passes:
python -m venv build/venv
. build/venv/bin/activate
python -m pip install ${sccPackage}
@pradyunsg, on Fedora 29 I can reproduce like this:
rm -rf ~/.local/lib/python3.7
sudo dnf install python3-pip
pip3.7 install -U --user pip
python3.7 -m pip install requests
```
Traceback (most recent call last):
File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/__main__.py", line 19, in
sys.exit(_main())
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
File "
File "
File "
File "
File "
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in
from pip._internal.cli.req_command import RequirementCommand
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 20, in
from pip._internal.operations.prepare import RequirementPreparer
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 16, in
from pip._internal.distributions import (
File "/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/home/kaiant/.local/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)
I just got this when my deployment auto-upgraded pip from 19.3.1 to 20.0
Everything is already using python -m pip - that is not the issue here
I can tell you that the fix from JediKev, that is to delete this folder:
site-packages/pip/_internal/distributions/source
fixed the problem
A plain Python Docker context using the python:3.7-slim
container (Debian-based) is also affected:
[32;1m$ docker build --compress -t $REGISTRY_IMAGE_SPARROW .[0;m
#2 [internal] load .dockerignore
#2 transferring context: 493B done
#2 DONE 0.0s
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.22kB done
#1 DONE 0.0s
#3 [internal] load metadata for docker.io/library/python:3.7-slim
#3 DONE 0.8s
#4 [base 1/6] FROM docker.io/library/python:3.7-slim@sha256:5886bc9424f2edc...
#4 DONE 0.0s
#5 [internal] load build context
#5 transferring context: 531.72kB 0.0s done
#5 DONE 0.0s
#10 [base 6/6] RUN pip install --upgrade pip
#10 CACHED
#8 [base 4/6] RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards co...
#8 CACHED
#9 [base 5/6] WORKDIR /app
#9 CACHED
#6 [base 2/6] COPY docker-entrypoint.sh /usr/local/bin/
#6 CACHED
#7 [base 3/6] RUN chmod +x /usr/local/bin/docker-entrypoint.sh
#7 CACHED
#11 [requirements 1/2] COPY requirements.txt requirements.txt
#11 CACHED
#12 [requirements 2/2] RUN pip install --no-cache-dir -r requirements.txt
#12 0.912 Traceback (most recent call last):
#12 0.912 File "/usr/local/bin/pip", line 8, in <module>
#12 0.912 sys.exit(main())
#12 0.912 File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
#12 0.912 command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
#12 0.912 File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
#12 0.912 module = importlib.import_module(module_path)
#12 0.912 File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
#12 0.912 return _bootstrap._gcd_import(name[level:], package, level)
#12 0.912 File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
#12 0.912 File "<frozen importlib._bootstrap>", line 983, in _find_and_load
#12 0.912 File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
#12 0.912 File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
#12 0.913 File "<frozen importlib._bootstrap_external>", line 728, in exec_module
#12 0.913 File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
#12 0.913 File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
#12 0.913 from pip._internal.cli.req_command import RequirementCommand
#12 0.913 File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
#12 0.913 from pip._internal.operations.prepare import RequirementPreparer
#12 0.913 File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
#12 0.913 from pip._internal.distributions import (
#12 0.913 File "/usr/local/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
#12 0.913 from pip._internal.distributions.source import SourceDistribution
#12 0.913 ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/usr/local/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)
#12 ERROR: executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt]: runc did not terminate sucessfully
------
> [requirements 2/2] RUN pip install --no-cache-dir -r requirements.txt:
------
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt]: runc did not terminate sucessfully
Got the same thing in python:3.7.6-alpine
running on github actions
I can reproduce this error in a Dockerfile
:
FROM python:3.7
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
CMD pip --version
And in requirements.txst
:
When I build this image, i get this nasty error. If I remove the line that upgrades pip, the image builds.
Okay, I have reproduced this locally -- I'll file a PR with a fix soon.
Removing folder ./site-packages/pip/_internal/distributions/source helps!
Yeah, pip version 20.0 breaks
Yep, having the same issue here (pip 20.0).
Yep, pip 20.0 breaks , using "virtualenv ." command to create venv
Same here, all of our CI builds that update pip are failing.
All builds are broken due to the same error on our end too.
Builds broke
What if I roll back to pip 19.x? Would it work?
EDIT:
pip install --upgrade "pip==19.3.1"
still works.
Same here with python 3.7.3 and pip 20.0
pip install pip"<20.0"
temp solution but it works.
perhaps is it possible to create a virtualenv
seting pip
versio to 19.3.1 (the prev.)
A quick fix which is working is
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip==9.0.2
Saved our CI pipeline
Read The Docs is also plagued by this issue now, making building of documents consistently fail
perhaps is it possible to create a virtualenv seting pip versio to 19.3.1 (the prev.)
@manutero, the --no-download
flag of the virtualenv
command will avoid trying to download the latest version of pip
at the time of creating the environment.
If you use virtualenv just downgrade to 19.x. This resolved the issue in my virtualenv:
virtualenv --no-pip <ENV NAME>
# activate the virtual environment
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip==19.2.2
Had to select the previous version to sort out,
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip=19.3.1
Same here with python 3.7.6 and pip 20.0
pip version-20.0
python version - 3.6
Just write below lines in the file
from .legacy import SourceDistribution
Can others seeing this failure confirm that there's a source/ folder in pip/_internal/distributions?
If you can confirm that folder exists, don't make comment here -- use the ๐ reaction on this post. That folder does not exist, use the ๐ reaction.
same issue here with ubuntu 19.04
Successfully installed pip-20.0
Traceback (most recent call last):
File "/home/pippo/.venvs/test_pgm/bin/pip", line 10, in <module>
sys.exit(main())
File "/home/pippo/.venvs/test_pgm/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/pippo/.venvs/test_pgm/lib/python3.7/site-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 "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/pippo/.venvs/test_pgm/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/home/pippo/.venvs/test_pgm/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/home/pippo/.venvs/test_pgm/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
from pip._internal.distributions import (
File "/home/pippo/.venvs/test_pgm/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/home/pippo/.venvs/test_pgm/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)
It doesn't appear with pip==19.2.3 so for now I reverted it
Please stop reporting "me too". @pradyunsg is working on a fix right now
Yep. hitting this now worked yesterday.
snippet for pipenv users
wget https://bootstrap.pypa.io/get-pip.py -O get-pip.py
pipenv run python get-pip.py pip==19.3
For a quickfix,
$(which easy_install) pip==19.3
also works ok
For a quickfix,
$(which easy_install) pip==19.3
also works ok
Between all the temporary workarounds, only this one worked for me
I wonder what will happen when they remove easy_install... :) - How are we going to fix pip issues then?
Replacing pip install --upgrade pip
with pip install --upgrade pip"<20.0"
working here.
Had to select the previous version to sort out,
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip=19.3.1
It should be python3 get-pip.py pip==19.3.1
Replacing
pip install --upgrade pip
withpip install --upgrade pip"<20.0"
working here.
Help me in docker
RUN pip install --upgrade pip"<20.0"
Thanks @PabloCastellano! I'm just ignoring comments here now, since I don't want my heartrate going any higher. :)
Made the bugfix release. If that helped, use ๐ on this post. Otherwise, please write a comment with the error message.
XD
I don't want my heartrate going any higher. :)
Made the bugfix release.
@pradyunsg You've just lowered mine. Seems to work.
@SergeyLadutko :
Replacing
pip install --upgrade pip
withpip install --upgrade pip"<20.0"
working here.Help me in docker
RUN pip install --upgrade pip"<20.0"
try pip install --upgrade pip==19.3.1
ok let me run my build again
@pradyunsg Hats off for the fast fix, we really appreciate it <3 I can confirm that this fix has taken hold within CircleCI jobs, for anyone wondering.
Note that get-pip.py hasn't been updated yet -- that's because, well, I borked my own dev environment for get-pip when testing this. :)
I'll update that in the next few minutes.
Can confirm. pip==20.0.1
is working fine
@pradyunsg any CI improvements so that it doesn't happen in the future? A docker container would be sufficient. Would you accept PRs for this?
Note that get-pip.py hasn't been updated yet -- that's because, well, I borked my own dev environment for get-pip when testing this. :)
I'll update that in the next few minutes.
:) let us know when this will be good to go
I'll update that in the next few minutes.
Alrighty, pushed this now. The change should've propagated to bootstrap.pypa.io by now. Or it will really soon.
Our build now passed with get-pip.py thanks @pradyunsg
pip 20.0.1 working properly. Thanks @pradyunsg
I can confirm, the new pip
gets installed now that does not suffer from this error anymore. Thanks @pradyunsg !
Thanks @pradyunsg !!
thank you @pradyunsg ! so so much
thanks @pradyunsg for the quick fix! ๐
Thanks @pradyunsg for quick turnaround!
I think, the problem was created because there is a source
module directory as well as source.py
in the pip/_internal/distributions
path and that messes up the imports
In pip/_internal/distributions/__init__.py
have an import line:
from pip._internal.distributions.source import SourceDistribution # <-- here
from pip._internal.distributions.wheel import WheelDistribution
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
But there's also a source
dir with __init__.py
inside there,
env ๎ฐ ~/.../_internal/distributions ๎ฐ ls -ltr
total 32
-rw-r--r-- 1 user xxx 1294 Jan 21 18:02 wheel.py
-rw-r--r-- 1 user xxx 760 Jan 21 18:02 installed.py
-rw-r--r-- 1 user xxx 1425 Jan 21 18:02 base.py
drwxr-xr-x 3 user xxx 4096 Jan 21 18:02 source
-rw-r--r-- 1 user xxx 4201 Jan 21 18:19 source.py
-rw-r--r-- 1 user xxx 961 Jan 21 18:26 __init__.py
drwxr-xr-x 2 user xxx 4096 Jan 21 18:26 __pycache__
Hence that import will fail. Renaming the source.py
to _source.py
and changing the import in __init__.py
to from pip._internal.distributions._source import SourceDistribution
seems to fix it
@pradyunsg Hats off for the fast fix, we really appreciate it <3
Agreed, fantastic turnaround on the fix here!
Thanks @pradyunsg
Same error as above.
Python version: python-3.7.6
OS: Windows
Works after moving to PIP 19.3.1
Works great now, thanks.
Considering the nature of this bug, can you please remove 20.0 release from PYPA? https://pypi.org/project/pip/#history
Another question would what we could do to avoid a similar regression in the future.
Sorry everyone for the breakage, and thanks for working with us here to fix this breakage!
@xavfernandez figured out why this happened and we'll be making changes to our release process to prevent similar failures in the future: #7624
great work, thanks for the lightning fast turnaround!
Hello, I'm stuck in 20.0
All the commands that I tried return this error about 'SourceDistribution'.
pip install --upgrade pip
pip install pip "<20.0"
pip install --upgrade "pip==19.3.1"
I tired to uninstall too :
pip uninstall pip
python -m pip uninstall pip setuptools
Anyone have another solution to uninstall pip?
Ubuntu 18.04.3 LTS
Python 3.6.9
run in virtualenv
Hi @CharrierCoop! You should be able to download get-pip.py and install pip 20.0.1 using that.
Perfect !!
thank you @pradyunsg
can you please remove 20.0 release from PYPA?
No. We're not going to be deleting it. We have a standard-backed feature for "yanking" broken releases. Once PyPI adds support for that, we'll yank this release (if anyone cares by then).
See https://www.python.org/dev/peps/pep-0592/#motivation for more details.
sudo python get-pip.py pip==19.3.1"
fix this issue
sudo python get-pip.py pip==19.3.1"
fix this issue
thank you very much
sudo python get-pip.py pip==19.3.1"
fix this issue
No need this issue was fixed by @pradyunsg
Hi @CharrierCoop! You should be able to download get-pip.py and install pip 20.0.1 using that.
I tried doing the same on Raspberry Pi 4( Python 3.7.3, pip version - 20.0 and OS - Raspbian Buster Lite), but it wasn't successful.
ERROR: Could not find a version that satisfies the requirement pi p
ERROR: No matching distribution found for pip
Any solution?
@Gilf641 Please file a new issue -- it'll be easier to manage for the maintainers.
I'm gonna go ahead and close this issue now, since it seems like things are working for most users.
If you're still facing issues, please look for duplicates filed in earlier (since Jan 21, for pip 20.0) and if there are none, file a new issue.
Most helpful comment
Thanks @PabloCastellano! I'm just ignoring comments here now, since I don't want my heartrate going any higher. :)
Made the bugfix release. If that helped, use ๐ on this post. Otherwise, please write a comment with the error message.