Pipenv + Tumbleweed + AWS Lambda - pipenv not working

I’m working with AWS Lambda functions for the first time (and python first time as well) and in performing an AWS operation I got the message that pipenv had to be installed. The problem is, looking at pipenv for TW there is no build that is not broken and the newest one is last year which leads me to to believe that TW has abandoned pipenv. Looking for alternatives it looks like TW is going the way of supporting pyenv instead.

Has anyone come across this and more importantly knows of a solution?

I tried to uninstall/re-install pipenv but after it uninstall it was unavailable to install again. However, while I did have it, it gave this error trying to run it.

> pipenv
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pipenv.patched.pip._vendor.pkg_resources.ContextualVersionConflict: (platformdirs 3.5.1 (/usr/lib/python3.9/site-packages), Requirement.parse('platformdirs<4,>=3.9.1'), {'virtualenv'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pipenv", line 33, in <module>
    sys.exit(load_entry_point('pipenv==2023.3.20', 'console_scripts', 'pipenv')())
  File "/usr/bin/pipenv", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib64/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/pipenv/__init__.py", line 64, in <module>
    from .cli import cli
  File "/usr/lib/python3.9/site-packages/pipenv/cli/__init__.py", line 1, in <module>
    from .command import cli  # noqa
  File "/usr/lib/python3.9/site-packages/pipenv/cli/command.py", line 7, in <module>
    from pipenv.cli.options import (
  File "/usr/lib/python3.9/site-packages/pipenv/cli/options.py", line 4, in <module>
    from pipenv.project import Project
  File "/usr/lib/python3.9/site-packages/pipenv/project.py", line 19, in <module>
    from pipenv.environment import Environment
  File "/usr/lib/python3.9/site-packages/pipenv/environment.py", line 21, in <module>
    from pipenv.patched.pip._vendor import pkg_resources
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 3252, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3.9/site-packages/pipenv/patched/pip/_vendor/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pipenv.patched.pip._vendor.pkg_resources.DistributionNotFound: The 'platformdirs<4,>=3.9.1' distribution was not found and is required by virtualenv

which is moot since the only versions for TW are out of date and broken so no sense in trying to troubleshoot this, I just put it here for completeness.

Request 744742: Delete python-pipenv - openSUSE Build Service - 4 years ago.

There seems to be only one package (python-dparse) which just Recommends it. Besides the project seems to be a wee deadish (gh#pypa/pipenv#3978).

Apparently, it was a mistake, because briefly looking at GitHub project, it is pretty much alive. Nothing prevents re-adding it to Tumbleweed, it just needs someone actually doing it (and maintaining this package further).

I have no idea about this software, but the very first hit of google search is its home page which says

The recommended way to install pipenv on most platforms is to install from pypi using pip:
$ pip install --user pipenv

I tried that and I got:

> pip install --user pipenv
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try
    zypper install python311-xyz, where xyz is the package
    you are trying to install.
    
    If you wish to install a non-rpm packaged Python package,
    create a virtual environment using python3.11 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-rpm packaged Python application,
    it may be easiest to use `pipx install xyz`, which will manage a
    virtual environment for you. Install pipx via `zypper install python311-pipx` .

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

so I figured that wasn’t an option on Suse.

I did however get it installed again by using the most up to date source https://build.opensuse.org/projects/home:jayvdb:other_peoples_important_tools/packages/python-pipenv/repositories/openSUSE_Tumbleweed/binaries but it is still broken.

This is standard upstream feature.

Did you read it to the end?

Arguably, it should not display this warning for user installs.

That worked. I was even able to install it without the --user option and so far things seem to be working.