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.

pipenv install --system cannot find python path

See original GitHub issue

When executing pipenv install --system using pipenv 8.1.2 or older, everything works as normal. When using pipenv version 8.1.3 or newer, pipenv cannot find the path to python.

  1. Environment: I run this inside a docker container: tensorflow:1.3.0-gpu-py3 using nvidia-docker
  2. Python version: 3.5.2
  3. Python location: /usr/bin/python
  4. Pipenv version: 8.1.3 or newer
Expected result

No thrown exception

Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock!
Installing dependencies from Pipfile.lock…
Actual result

The following exception is thrown:

Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Error [Errno 2] No such file or directory: '/bin/python' while executing command python setup.py egg_info
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/cli.py", line 1738, in install
    do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/cli.py", line 1250, in do_init
    do_lock(system=system)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/cli.py", line 1069, in do_lock
    pre=pre
  File "/usr/local/lib/python3.5/dist-packages/pipenv/utils.py", line 425, in resolve_deps
    resolved_tree.update(resolver.resolve())
  File "/usr/local/lib/python3.5/dist-packages/piptools/resolver.py", line 101, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/local/lib/python3.5/dist-packages/piptools/resolver.py", line 198, in _resolve_one_round
    for dep in self._iter_dependencies(best_match):
  File "/usr/local/lib/python3.5/dist-packages/piptools/resolver.py", line 284, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/usr/local/lib/python3.5/dist-packages/piptools/repositories/pypi.py", line 170, in get_dependencies
    self._dependencies_cache[ireq] = reqset._prepare_file(self.finder, ireq)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/patched/pip/req/req_set.py", line 634, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/lib/python3.5/dist-packages/pipenv/patched/pip/req/req_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/lib/python3.5/dist-packages/pipenv/patched/pip/req/req_install.py", line 447, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python3.5/dist-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
    cwd=cwd, env=env)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python'
Steps to replicate

pip install pipenv==8.1.3 pipenv install --system

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
Jitsusamacommented, Mar 22, 2018

Ok, I’ve done some investigating, and I’ve been able to make it work in a way that’s not too hacky. As an aside, my main reason for doing this is because pipenv doesn’t work on my Windows PC due to a corporate firewall that thinks it’s a virus 😛

Here are my steps for reproducing the issue:

# docker run --rm -it --entrypoint /bin/bash python:3.6-slim
root@adbc1b6c3752:/# mkdir app && cd app
root@adbc1b6c3752:/app# echo '[[source]]
> url = "https://pypi.python.org/simple"
> verify_ssl = true
> name = "pypi"
>
> [packages]
> requests = "*"
>
> [requires]
> python_version = "3.6"' > Pipfile
root@adbc1b6c3752:/app# pip install -q --upgrade pipenv
root@adbc1b6c3752:/app# pipenv install --system
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
/python: not found

I tried to track down what was giving this error and had no luck, then I discovered that there is a verbose option to pipenv install. I used that and had the following results:

root@adbc1b6c3752:/app# pipenv install -v --system
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…

/bin/sh: 1: /bin/python: not found

I tried to figure out which script referenced /bin/python, but to no avail. So I thought, well, I can fix this easy enough:

root@adbc1b6c3752:/app# ln -sf $(which python) /bin/python
root@adbc1b6c3752:/app# pipenv install --system
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (7b8df8)!
Installing dependencies from Pipfile.lock (7b8df8)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 —

When adding the symbolic link function into my Dockerfile, I’m able to do this all dynamically. I understand from @kennethreitz that this goes against the very principle of pipenv, mainly being that when you deploy your application, you have the versions already pinned. I agree with him. In my case, I’m simply using this method to generate my Pipfile.lock since I can’t generate it on my development workstation.

If you are interested though, here is what the Dockerfile could look like:

FROM python:3.6-slim

WORKDIR /app
COPY Pipfile ./
RUN set -x \
 && ln -sf /usr/local/bin/python /bin/python \
 && pip install --upgrade pipenv==11.9.0 \
 && pipenv install --system
1reaction
Groniscommented, Nov 17, 2017

Hi @erinxocon , the reason it works for you, is because you are missing the slash before notebooks, and pipenv does not find the Pipfile (since it is not in working directory). For your Dockerfile, it does not crash, but the result is a docker container without any dependencies from the Pipfile.

This Dockerfile does not work: (e.g with /notebooks rather than notebooks)

FROM tensorflow/tensorflow:1.3.0-gpu-py3

ENV LC_ALL=C.UTF-8 \
    LANG=C.UTF-8 \
    PIPENV_HIDE_EMOJIS=1

RUN set -ex && pip install pipenv --upgrade

COPY Pipfile /notebooks/Pipfile
RUN set -ex && pipenv install --system

I have also tested this Dockerfile with pipenv version 8.3.2 and the bug still persist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pipenv doesn't find correct python version on $PATH without ...
When multiple versions of python 3 are installed on $PATH and pyenv is not available, then pipenv will only look at /usr/bin/python3 and...
Read more >
Why can't Pipenv find the correct version of python for my venv?
I am having a similar workflow when it comes to installing Python (using both Pyenv and Pipenv). This is working for me: Install...
Read more >
Configure a Pipenv environment | IntelliJ IDEA Documentation
Install Pipenv  · Run the following command to find the user base's binary directory: $ python -m site --user-base · Add bin...
Read more >
pipenv · PyPI
Commands. Locate the Project. Locate the virtualenv. Locate the Python Interpreter. Install Packages. Installing from git. Install a dev dependency.
Read more >
Using Python environments in VS Code
Using Python environments in VS Code. This article discusses the helpful Python environments features available in Visual Studio Code. An "environment" in ...
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