question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get rid of which dependency in system_which

See original GitHub issue
Issue description

In many minimal system installations (container distributions, etc., see #2277) the non-standard command which is not available by default. But pipenv currently requires this in order to find python and other tools. One could say, that this is a packager fail, but I think, the requirements for pipenv should be minimal and there are many other ways to find executables apart from which.

Expected result

pipenv should work in most plank standard container images out of the box.

Actual result

Pipenv fails and you have to specify the python executable with --python argument.

Steps to replicate
$ docker run --rm -it fedora:28 bash
# dnf install pipenv
# pipenv --three
Warning: the which -a system utility is required for Pipenv to find Python installations properly.
  Please install it.
Warning: the which -a system utility is required for Pipenv to find Python installations properly.
  Please install it.
Warning: the which -a system utility is required for Pipenv to find Python installations properly.
  Please install it.
Warning: Python 3 was not found on your system…
You can specify specific versions of Python with:
  $ pipenv --python path/to/python
When possible, provide the verbose output (`--verbose`), especially for locking and dependencies resolving issues.
Ideas to solve it
  • I’ve no idea how what we can do on windows. For Linux, these few python lines do more or less the same as which:
def _which(command: str):
      def is_exe(fpath):
          return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

      fpath, _fname = os.path.split(command)
      if fpath:
          if is_exe(command):
              return command
      else:
          for path in os.environ["PATH"].split(os.pathsep):
              exe_file = os.path.join(path, command)
              if is_exe(exe_file):
                  return exe_file

      return None
  • Apart from which, command -v is more standard and available in most shells
  • When --three is given and sys.version_info.major == 3, you could just use sys.executable. The same applies for --two and so on.

$ pipenv --support This is from a `fedora:29` beta docker image, as pipenv in `fedora:28` has no `--support` argument. The same issue is present on fedora 29 as well.

Pipenv version: '2018.7.1'

Pipenv location: '/usr/lib/python3.7/site-packages/pipenv'

Python location: '/usr/bin/python3'

Other Python installations in PATH:

Warning: the which -a system utility is required for Pipenv to find Python installations properly. Please install it. […] PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.18.7-300.fc29.x86_64',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Mon Sep 10 15:37:17 UTC 2018',
 'python_full_version': '3.7.0',
 'python_version': '3.7',
 'sys_platform': 'linux'}

System environment variables:

  • LANG
  • HOSTNAME
  • PWD
  • HOME
  • FBR
  • DISTTAG
  • FGC
  • TERM
  • SHLVL
  • PATH
  • _
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • LANG: en_US.UTF-8
  • PWD: /

Contents of Pipfile (‘/Pipfile’):


Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
abbasegbeyemicommented, Apr 19, 2021

Encountering the same problem here as well. What’s the solution?

2reactions
Eelvinycommented, Jan 27, 2021

I’m encountering this warning when using the new AWS Lambda distributable for Python. This is a container runtime so I’m using pipenv install within a Dockerfile. As I’m already explicitly specifying the version I don’t have issues but these new container runtimes don’t contain which.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing Dependencies: One Weird Trick for Increasing ...
Multiple Reasons to Remove? In some cases, the answers to multiple questions posed above suggest dependency removal in favor of dependency ...
Read more >
How to Remove a Dependency from a Windows Service
Before running the above, make sure that there is only one dependency, or that you know all of the dependencies so that you...
Read more >
Tag Archives: how to remove all dependency from system form
Posts about how to remove all dependency from system form written by Rawish Kumar Prajapati.
Read more >
Is there a simple way to remove unused dependencies from a ...
DepClean is a tool to automatically remove dependencies that are included in your Java dependency tree but are not actually used in the...
Read more >
How to eliminate (or deal with) hidden dependencies
Getting Rid of Hidden Dependencies · Write code that's truly modular, not just split across multiple files. · Reduce the number of assumptions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found