Pipenv: Pipenv does not find pipfile in upper directory

Created on 9 Mar 2018  路  9Comments  路  Source: pypa/pipenv

Pipenv virtualenv created for a project, at the top of my project are a pipfile and pipfile.lock files.
When executing pipenv commands in sub directory (3 levels below), a new virtual env gets created.

I thought it would not be the case and pipenv would use the one at the top

Describe your environment
  1. OS Type: Windows 10
  2. Python version: $ python -V Python 3.6.1 :: Anaconda 4.4.0 (64-bit)
  3. Pipenv version: $ pipenv --version pipenv, version 11.1.6
Expected result

I expect no new environment to be created

Actual result

Passing the option --verbose to pipenv does not work

Steps to replicate
  • created a virtualenv with pipenv, and a pipfile
  • create some subdirs
  • in the subdir, execute pipenv --shell
    It creates a new env instead of using the one at the top.
    Please note that sometimes it works, sometimes not.

Top Pipfile
[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]

"pyqt5" = ""
pyedflib = "
"
psutil = "*"

[dev-packages]

[requires]

python_version = "3.6"

Most helpful comment

We only check 2 or 3 levels above. This is configurable by setting the PIPENV_MAX_DEPTH environment variable.

All 9 comments

We only check 2 or 3 levels above. This is configurable by setting the PIPENV_MAX_DEPTH environment variable.

How can I pass it to pipenv then ?

Ok, I defined the variable ang finally got pipenv finding the venv.

Nevertheless, while in my sub dir, while typing pipenv shell, the shell started correctly but 3 level above, next to the venv, not in the current directory. It is a bit annoying.

I cd back to my script, then tried to run it. The script complained about not being able to import packages as absolute import. It looks like something is not functioning correctly regarding absolute and relative paths in this situation.

set PIPENV_MAX_DEPTH=5 or whatever.

Pipenv will always drop you at your project root when you launch a subshell. As for absolute imports, you鈥檒l want to consult the python docs on why you鈥檙e getting that error

Thanks ! I already figured out the env variable.

Out of curiosity, PIPENV_MAX_DEPTH=2 or 3 by default, why such a low number by default ? what is the reasoning ?

Nevertheless, I would prefer that pipenv, by design, while in a shell and typing pipenv shell leaves you at your current location.

For the wrong absolute imports, this is probably something else.

you're the first person who's raised any concern over the default so far, so i think we've picked a good sane default :)

I'll see about adding an env var to not chdir when invoking shell

That would be good; I've just run into this. It's nice to be able to use pipenv run without pipenv run sh -c "cd foo && actual-cmd"

Was this page helpful?
0 / 5 - 0 ratings