When running pip-compile, the following error occurs:
AttributeError: module 'pip._internal.download' has no attribute 'is_file_url'
OS Type
Mac OS X (also occurring on Windows 10)
Python version: $ python -V
3.6.5
pip version: $ pip --version
19.3.1 (also present in 19.3)
pip-tools version: $ pip-compile --version
It says I downloaded pip-tools 4.3.0, but anytime I type pip-compile, it returns that same error: AttributeError: module 'pip._internal.download' has no attribute 'is_file_url'
pip-compilepip-compile would run, creating an updated requirements.txt using the requirements.in file in the directory.
...
$ pip-compile
Traceback (most recent call last):
File "/usr/local/bin/pip-compile", line 6, in <module>
from piptools.scripts.compile import cli
File "/usr/local/lib/python3.6/site-packages/piptools/scripts/compile.py", line 11, in <module>
from .._compat import InstallCommand, install_req_from_line, parse_requirements
File "/usr/local/lib/python3.6/site-packages/piptools/_compat/__init__.py", line 7, in <module>
from .pip_compat import (
File "/usr/local/lib/python3.6/site-packages/piptools/_compat/pip_compat.py", line 35, in <module>
is_file_url = do_import("download", "is_file_url")
File "/usr/local/lib/python3.6/site-packages/piptools/_compat/pip_compat.py", line 24, in do_import
return getattr(imported, package)
AttributeError: module 'pip._internal.download' has no attribute 'is_file_url'
I noticed this issue in https://github.com/jazzband/pip-tools/issues/981 and tried to replicate the solution by downgrading pip to 19.2 as well as downgrading pip-tools to 4.2.0, neither of which fixed the issue.
...
Hi @blairg23,
Thanks for the issue! Could you please paste here the output from the following commands?
$ which pip-compile
$ pip --version
$ pip2 --version
$ pip3 --version
I'm seeing a related issue. Everything works with pip 19.3, but not the new 20.0.1
$ pip-sync --version
pip-sync, version 4.2.0
WARNING: You are using pip version 19.3; however, version 20.0.1 is available.
$ pip-sync --version
Traceback (most recent call last):
File "/code/venv/bin/pip-sync", line 6, in <module>
from piptools.scripts.sync import cli
File "/code/venv/lib/python3.7/site-packages/piptools/scripts/sync.py", line 7, in <module>
from .. import click, sync
File "/code/venv/lib/python3.7/site-packages/piptools/sync.py", line 8, in <module>
from ._compat import DEV_PKGS, stdlib_pkgs
File "/code/venv/lib/python3.7/site-packages/piptools/_compat/__init__.py", line 7, in <module>
from .pip_compat import (
File "/code/venv/lib/python3.7/site-packages/piptools/_compat/pip_compat.py", line 39, in <module>
PackageFinder = do_import("index", "PackageFinder")
File "/code/venv/lib/python3.7/site-packages/piptools/_compat/pip_compat.py", line 26, in do_import
return getattr(imported, package)
AttributeError: module 'pip._internal.index' has no attribute 'PackageFinder'
I think this may be an issue with python==3.6.5. I'm running these same versions of pip and pip-tools on different machines using a virtualenv with python==3.7.4 with success. One interesting thing to note... on my Mac OS X with python==3.7.4 installed as the virtualenv Python installation,, it appears that it is still attempting to use the piptools library from python3.6.
```
─[email protected] ~/Desktop/sandboxes/python/expense-analysis ‹development›
╰─➤ python
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
exit()
â•─[email protected] ~/Desktop/sandboxes/python/expense-analysis ‹development›
╰─➤ pip-compile
Traceback (most recent call last):
File "/usr/local/bin/pip-compile", line 6, in
from piptools.scripts.compile import cli
File "/usr/local/lib/python3.6/site-packages/piptools/scripts/compile.py", line 11, in
from .._compat import InstallCommand, install_req_from_line, parse_requirements
File "/usr/local/lib/python3.6/site-packages/piptools/_compat/__init__.py", line 7, in
from .pip_compat import (
File "/usr/local/lib/python3.6/site-packages/piptools/_compat/pip_compat.py", line 35, in
is_file_url = do_import("download", "is_file_url")
File "/usr/local/lib/python3.6/site-packages/piptools/_compat/pip_compat.py", line 24, in do_import
return getattr(imported, package)
AttributeError: module 'pip._internal.download' has no attribute 'is_file_url'
This actually may be due to me having python3.6 and python3.7 installed on my Mac.
Can confirm, once I updated python by doing brew upgrade python, it reset the symlinks so that python3 now points to python3.7 and pip-compile now works as expected.
For me, upgrading to the latest version of pip-tools solved this issue.
pip install -U pip
pip install -U pip-tools
Most helpful comment
For me, upgrading to the latest version of pip-tools solved this issue.