pipenv: PipEnv fails installs with TypeError ('LegacySpecifier' not iterable)
PipEnv fails some installs with an exception, TypeError: 'LegacySpecifier' object is not iterable:
$ pip3 freeze | grep pipenv
pipenv==2020.11.15
Installation should work or show an actual error related to a package. It fails on a TypeError exception without any legible problem report related to the install:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/resolver.py", line 764, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/resolver.py", line 760, in main
dev=parsed.dev)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/resolver.py", line 741, in _main
resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/resolver.py", line 709, in resolve_packages
requirements_dir=requirements_dir,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/resolver.py", line 692, in resolve
req_dir=requirements_dir
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 1403, in resolve_deps
req_dir=req_dir,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 1110, in actually_resolve_deps
resolver.resolve_constraints()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/utils.py", line 862, in resolve_constraints
marker = marker_from_specifier(candidate.requires_python)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/markers.py", line 719, in marker_from_specifier
for marker_segment in cleanup_pyspecs(spec):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/markers.py", line 288, in cleanup_pyspecs
for op_and_version_type, versions in _group_by_op(tuple(specs)):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/markers.py", line 203, in _group_by_op
specs = [_get_specs(x) for x in list(specs)]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/markers.py", line 203, in <listcomp>
specs = [_get_specs(x) for x in list(specs)]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/markers.py", line 187, in _get_specs
for spec in set(specset):
TypeError: 'LegacySpecifier' object is not iterable
Verbose log is attached as a file.
I believe this is related to parsing markers, e.g. importlib-metadata>=3.6 ; python_version<='3.7'. However, I have not deep dived very far into the cause.
Reproduce:
rm -r dist *.egg* ; pip3 uninstall exotic ; rm -rf Pipfile* rm -rf ~/.local/share/virtualenvs/somelocalappname*
pipenv --verbose install
You could probably reproduce it by simply installing the EXOTIC product, which is a dependency of somelocalappname:
pipenv install exotic
IT WORKS WITH AN OLDER VERSION OF PIPENV:
pip3 uninstall pipenv ; pip3 install pipenv==2018.11.26
someorgs-MacBook-Pro:somelocalappname someuser$ pipenv --support
$ pipenv --support
Pipenv version: '2020.11.15'
Pipenv location: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv'
Python location: '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3'
Python installations found:
3.7.3:/Library/Frameworks/Python.framework/Versions/3.7/bin/python33.7.3:/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m3.7.3:/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.73.7.3:/usr/local/bin/python33.7.3:/usr/local/bin/python3.7m3.7.3:/usr/local/bin/python3.7
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.7.3',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '19.6.0',
'platform_system': 'Darwin',
'platform_version': 'Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST '
'2021; root:xnu-6153.141.16~1/RELEASE_X86_64',
'python_full_version': '3.7.3',
'python_version': '3.7',
'sys_platform': 'darwin'}
System environment variables:
TERM_PROGRAMTERMSHELLTESTRAIL_KEYTMPDIRTERM_PROGRAM_VERSIONOLDPWDTERM_SESSION_IDUID_GIDUSERTERM_SESSION_CLASS_IDSSH_AUTH_SOCKBASH_SILENCE_DEPRECATION_WARNINGMAVEN_OPTSMAVEN_HOMEPATHPWDJAVA_HOMELANGARTIFACTORY_PSWTEST_PSWPYTHONHOMEXPC_FLAGSTESTRAIL_USERXPC_SERVICE_NAMEARTIFACTORY_USRM2_HOMEHOMESHLVLTEST_USRPYTHONPATHLOGNAMETESTRAIL_PSWTESTRAIL_USR___CF_USER_TEXT_ENCODINGPIP_DISABLE_PIP_VERSION_CHECKPYTHONDONTWRITEBYTECODEPIP_SHIMS_BASE_MODULEPIP_PYTHON_PATHPYTHONFINDER_IGNORE_UNSUPPORTED
Pipenvspecific environment variables:
Debugspecific environment variables:
PATH:/Library/Java/JavaVirtualMachines/jdk-1.8.0_232.jdk/Contents/Home/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/someuser/Library/Python/3.7/bin:/opt/maven/latest/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/binSHELL:/bin/zshLANG:en_US.UTF-8PWD:/proj/survey-ws/source/somelocalappname
Contents of Pipfile (‘/System/Volumes/Data/proj/survey-ws/source/somelocalappname/Pipfile’):
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
astropy = ">=4.0.1.post1"
beautifulsoup4 = "~=4.9"
dawgie = "~=1.2"
exotic = "~=0.41.0"
filelock = "~=3.0"
importlib-metadata = ">=3.6"
json2html = "~=1.3"
jdcal = "~=1.4.1"
jplephem = ">=2.14"
lmfit = "~=1.0.1"
matplotlib = ">=3.2.2"
paramiko = ">=2.7.2"
pymc3 = "~=3.9"
pytz = ">=2019.3"
pytesseract = "~=0.2.9"
python-dateutil = "~=2.8.1"
requests = "~=2.23"
scipy = "~=1.4"
skyfield = "~=1.18"
statsmodels = ">=0.12.0"
tenacity = "~=5.1"
LDTk = "~=1.4.1"
TwitterAPI = "~=2.5"
[dev-packages]
[requires]
python_version = "3.7"
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (15 by maintainers)
Agreed that the version quotes provoked an issue in
pipenvbut it didn’t result in errors withpip. Installation fails were only experienced inpipenv. The Versioning PEPs are a bit amorphous as some indicate quotes and others don’t. Also, the Setup Tools documentation lacks detail forpython_requiresarguments insetup.py. Anyway, as removing the quotes will only help, the PR will integrated.Just to clear some misunderstanding, the error manifested with installing the requirements file by itself, and the requirements file doesn’t reference
EXOTIC. It does however contain markers, similar toimportlib-metadata>=3.6 ; python_version<='3.7'. Installing only therequirementsfile intopipenvfailed with theLegacySpecifiererror.There may have been a component of system configuration cruft confounding this. Now I’ve completely reset my
pipandpipenvinstallations, including removing caches and pulling entirely new distributions. Without updatingEXOTICwith the PR, the error is no longer reproducible.Here’s how I reset the environment:
I think we can call this closed. I’m quite certain a year ago this was a problem with the older release. If any similar errors arise again in the context of a
requirementsfile, I will raise a new issue to cleanly indicate that. Thanks for working on Pipenv which is ultimately a great tool.@jpl-jengelke Yes that is the one, and fwiw I am trying it right now, just installed Cython first. Its still running … not sure how long it should take. I’ll edit this message hopefully soon. EDIT: Well I think I reproduced your bug, I was hopeful it would have been fixed as well.
Just to confirm, I retested just today with
2022.1.8.which is the log in my last post. I’ll try to scrape some time together to test with the new branch.@matteius Do you mean the branch named
vendor-pip-22.0.3-followup-changes?