Problem
While trying to use pipenv to manage python dependencies, I noticed that I got the following error when trying to convert the Pipfile.lock
to a requirements.txt file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(my-app) ┌─[ryan@host] – [~/Documents/git/my-repo] – [Wed Oct 05, 14:29] | |
└─[$] pipfile2req Pipfile.lock > requirements.txt | |
Traceback (most recent call last): | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/bin/pipfile2req", line 8, in | |
sys.exit(main()) | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pipfile2req/init.py", line 112, in main | |
lines = convert_pipfile_or_lock( | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pipfile2req/init.py", line 96, in convert_pipfile_or_lock | |
lines = [ | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pipfile2req/init.py", line 97, in | |
requirement_from_pipfile(name, package, hashes) | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pipfile2req/requirements.py", line 10, in requirement_from_pipfile | |
return Requirement.parse(name, package).as_line(include_hashes) | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pipfile2req/requirements.py", line 97, in parse | |
kwargs["markers"] = _merge_markers(markers) | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pipfile2req/requirements.py", line 14, in _merge_markers | |
result = Marker(markers[0]) | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/packaging/markers.py", line 278, in init | |
self._markers = _coerce_parse_result(MARKER.parseString(marker)) | |
File "/Users/ryan/.local/share/virtualenvs/my-app-g5SfM111/lib/python3.9/site-packages/pyparsing.py", line 1941, in parseString | |
instring = instring.expandtabs() | |
AttributeError: 'NoneType' object has no attribute 'expandtabs' |
Upon further inspection, I discovered that in some cases the marker value in the Pipfile.lock
was null which caused the pipfile2req
program to crash.
Solution
The issue had been pipenv was version 2022.9.20
which introduced the issue. I was able to uninstall using pip uninstall pipenv
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌─[ryan@host] – [~] – [Wed Oct 05, 16:58] | |
└─[$] <> pip uninstall pipenv | |
Found existing installation: pipenv 2022.9.20 | |
Uninstalling pipenv-2022.9.20: | |
Would remove: | |
/Users/ryan/.pyenv/versions/3.9.6/bin/pipenv | |
/Users/ryan/.pyenv/versions/3.9.6/bin/pipenv-resolver | |
/Users/ryan/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pipenv-2022.9.20.dist-info/* | |
/Users/ryan/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pipenv/* | |
Proceed (Y/n)? Y | |
Successfully uninstalled pipenv-2022.9.20 |
Then I re-installed pipenv with the latest version(2022.10.4 at the time of this writing).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌─[ryan@host] – [~] – [Wed Oct 05, 16:58] | |
└─[$] <> pip install pipenv | |
Collecting pipenv | |
Downloading pipenv-2022.10.4-py2.py3-none-any.whl (3.3 MB) | |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 8.9 MB/s eta 0:00:00 | |
Requirement already satisfied: virtualenv-clone>=0.2.5 in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from pipenv) (0.5.7) | |
Requirement already satisfied: setuptools>=36.2.1 in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from pipenv) (57.5.0) | |
Requirement already satisfied: certifi in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from pipenv) (2022.6.15) | |
Requirement already satisfied: virtualenv in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from pipenv) (20.15.0) | |
Requirement already satisfied: filelock<4,>=3.2 in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from virtualenv->pipenv) (3.7.1) | |
Requirement already satisfied: platformdirs<3,>=2 in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from virtualenv->pipenv) (2.5.2) | |
Requirement already satisfied: distlib<1,>=0.3.1 in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from virtualenv->pipenv) (0.3.4) | |
Requirement already satisfied: six<2,>=1.9.0 in ./.pyenv/versions/3.9.6/lib/python3.9/site-packages (from virtualenv->pipenv) (1.16.0) | |
Installing collected packages: pipenv | |
Successfully installed pipenv-2022.10.4 |
That resolved the issue of putting null markers in the Pipfile.lock file for packages.