pipupgrade
pipupgrade copied to clipboard
pipupgrade --requirements requirements_dev.txt hits an AttributeError
What's the bug all about?
When running pipupgrade --requirements requirements_dev.txt
we hit a stack trace from the internal library.
Versions
pip ==20.1.1 python == 3.7.3 pipupgrade == 1.5.1
What command led to this issue?
python@82d35b4dd03a:~/app$ pipupgrade --check
Source: Installed Distributions (/usr/local/bin/pip)
Name Current Version Latest Version Home Page
----------------- --------------- -------------- ---------------------------------------------------
boto3 1.9.178 1.14.8 https://github.com/boto/boto3
botocore 1.12.253 1.17.8 https://github.com/boto/botocore
docutils 0.15.2 0.16 http://docutils.sourceforge.net/
fakeredis 1.0.3 1.4.1 https://github.com/jamesls/fakeredis
lazy-object-proxy 1.4.3 1.5.0 https://github.com/ionelmc/python-lazy-object-proxy
metric-logger 1.3.5 1.3.6 None
pipeline-cache 0.2.0 1.0.0 None
pipupgrade 1.5.1 1.7.2 https://github.com/achillesrasquinha/pipupgrade
pylint 2.4.1 2.5.3 https://github.com/PyCQA/pylint
redis 3.1.0 3.5.3 https://github.com/andymccurdy/redis-py
s3transfer 0.2.1 0.3.3 https://github.com/boto/s3transfer
urllib3 1.24.3 1.25.9 https://urllib3.readthedocs.io/
wheel 0.33.1 0.34.2 https://github.com/pypa/wheel
python@82d35b4dd03a:~/app$ pipupgrade --requirements requirements_dev.txt
Checking...
Traceback (most recent call last):
File "/usr/local/bin/pipupgrade", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/pipupgrade/cli/__init__.py", line 14, in wrapper
return fn(**params)
File "/usr/local/lib/python3.7/site-packages/pipupgrade/commands/__init__.py", line 171, in command
registry = Registry(source = path, packages = packages, sync = no_cache)
File "/usr/local/lib/python3.7/site-packages/pipupgrade/model/registry.py", line 12, in __init__
self.packages = [Package(p, sync = sync) for p in packages]
File "/usr/local/lib/python3.7/site-packages/pipupgrade/model/registry.py", line 12, in <listcomp>
self.packages = [Package(p, sync = sync) for p in packages]
File "/usr/local/lib/python3.7/site-packages/pipupgrade/model/package.py", line 40, in __init__
""" % self.name)
AttributeError: 'Package' object has no attribute 'name'
python@82d35b4dd03a:~/app$ cat requirements_dev.txt
coverage
pylint==2.4.1
mypy
pytest
pytest-benchmark
pytest-cov
pytest-mock
requests_mock
wheel
metric_logger==1.3.5
pipeline_cache==0.2.0
pipupgrade==1.5.1
python@82d35b4dd03a:~/app$ pipupgrade --version
1.5.1
Logs
Please paste the logs using pipupgrade --verbose
python@010b0cc1528a:~/app$ pipupgrade --verbose --requirements requirements_dev.txt
Checking...
2020-06-22 22:47:38,799 | INFO | Arguments Passed: {'pip_path': None, 'requirements': ['requirements_dev.txt'], 'pipfile': None, 'project': None, 'pull_request': False, 'git_username': None, 'git_email': None, 'github_access_token': None, 'github_reponame': None, 'github_username': None, 'target_branch': 'master', 'self': False, 'user': False, 'check': False, 'interactive': False, 'yes': False, 'no_cache': False, 'no_color': False, 'verbose': True, 'latest': False}
2020-06-22 22:47:38,799 | INFO | `pip` executables found: ['/usr/local/bin/pip', '/usr/local/bin/pip3']
2020-06-22 22:47:38,810 | INFO | Requirements found: ['requirements_dev.txt']...
Traceback (most recent call last):
File "/usr/local/bin/pipupgrade", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/pipupgrade/cli/__init__.py", line 14, in wrapper
return fn(**params)
File "/usr/local/lib/python3.7/site-packages/pipupgrade/commands/__init__.py", line 171, in command
registry = Registry(source = path, packages = packages, sync = no_cache)
File "/usr/local/lib/python3.7/site-packages/pipupgrade/model/registry.py", line 12, in __init__
self.packages = [Package(p, sync = sync) for p in packages]
File "/usr/local/lib/python3.7/site-packages/pipupgrade/model/registry.py", line 12, in <listcomp>
self.packages = [Package(p, sync = sync) for p in packages]
File "/usr/local/lib/python3.7/site-packages/pipupgrade/model/package.py", line 40, in __init__
""" % self.name)
Can you upgrade to latest pipupgrade
? You can try
$ pipupgrade --self
Hello @achillesrasquinha. I'm, still hitting this on the latest version of pipupgrade an python.
[python@3eec2a2345ae lambda]$ pipupgrade -r requirements_dev.txt
Checking...
multiprocessing.pool.RemoteTraceback:
"""
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.8/site-packages/pipupgrade/model/package.py", line 99, in __init__
logger.info("Fetching package %s information from DB..." % self.name)
AttributeError: 'Package' object has no attribute 'name'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.8/site-packages/pipupgrade/commands/helper.py", line 357, in get_registry_from_requirements
registry = Registry(source = path, packages = packages, sync = sync,
File "/usr/local/lib/python3.8/site-packages/pipupgrade/model/registry.py", line 111, in __init__
for package in pool.imap_unordered(partial(Package, **args), packages):
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 865, in next
raise value
AttributeError: 'Package' object has no attribute 'name'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/pipupgrade", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/pipupgrade/cli/__init__.py", line 15, in wrapper
return fn(**params)
File "/usr/local/lib/python3.8/site-packages/pipupgrade/commands/__init__.py", line 161, in command
registries += results
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 865, in next
raise value
AttributeError: 'Package' object has no attribute 'name'
[python@3eec2a2345ae lambda]$ pipupgrade --version
1.7.2
Dowgrading to pip 19.x solved this issue for me:
pip install pip~=19.0
It fails with 20.2.4.
Came across this error myself with pipupgrade v1.8.2 and pip v20.3.3.
The package
arg of the Package class init seems to be of type ParsedRequirement as of pip v20.X, so no if
condition is met and self.name
(and current_version
) is never set
I managed to get it working by downgrading pip to 19.x as @macgeneral suggested.
I'm assuming unrelated to this issue, but I also needed to change the isinstance(package, _pip.InstallRequirement)
block from
if hasattr(package.req, "specifier"):
self.current_version = str(package.req.specifier)
to
if hasattr(package.req, "specifier"):
self.current_version = str(package.req.specifier).lstrip("==")
for the current_version
and Package.difference
calculation to work as expected (otherwise the current_version
was "==X.Y.Z" versus latest_version
of "X.Y.Z" and all package updates were included rather than the expected minor
and patch
)
Passing FYI - this is still a problem. But luckily this fix still works: https://github.com/achillesrasquinha/pipupgrade/issues/71#issuecomment-720118223