$ python -V
- Python 2.7.10$ pipenv --version
- pipenv, version 9.0.3cd ~/
pipenv install <any-package>
mkdir hello
cd hello
pipenv install <any-package>
Pipfile
and Pipfile.lock
should be created in the current directory (~/hello
in the above example)
If Pipfile
exist in home (parent) directory, no Pipfile
or Pipfile.lock
is created in current directory. pipenv
keeps adding packages to the parent Pipfile (in home directory in above example). And pipenv --where
returns home directory path.
This is deliberate, and normally is what people want. Say you鈥檙e developing a package with a tools
directory. It would be strange if you can鈥檛 run scripts inside the tools
subdirectory, only in the root. The Pipfile should work for all directories inside that project.
You can create a Pipfile manually inside hello
to get the behaviour you want.
I don't program in python and in fact I came across pipenv
today itself while working on a project. So my opinions might not be right. But I was expecting the tool to create Pipfile
in current directory if it does not exist. I was not aware that I had accidentally ran pipenv
in home directory and that a Pipfile
exists there - kept wondering why Pipfile
was not created in my project directory even though all commands succeed.
You are right that this might be an issue while running commands in subdirectories. Wonder if it would make sense to lookup the source-control root directory and generate the file there rather than using home? And if source-control not present, use default home path?
Again this is just an opinion, please feel free to close the issue if this is deliberate and desired behaviour.
While I don鈥檛 think the current behaviour is wrong, your experience might show a related issue: it is too easy for people to accidentally create a Pipfile. Currently there鈥檚 no explicit command required to create a Pipfile; almost all commands will create it automatically. I can recall several times I ran pipenv <something>
in the wrong directory and had to ctrl-c immediately before it create a Pipfile (and virtualenv) for my /etc
. There might be an enhancement worth considering.
(p.s. I am not one of the project maintainers; I鈥檒l just leave this here for them to triage on.)
@uranusjr thanks again as always for your ongoing help, it really means a great deal
@tejasbubane you can set the environment variable PIPENV_MAX_DEPTH
if you don't like pipenv recursing up your directory tree
Another, newer way to do it is to set the env variable PIPENV_NO_INHERIT
. Then Pipenv won't look in the parent directory.
I just ran into this issue as well (apparently there was a Pipfile in the parent directory but I didn't realize).
Can we add a debug message when this happens, something like (using /path/to/Pipfile)
, if we're not in the same directory as the Pipfile?
@sid-kap It has been added recently and will be in the next release :)
You can as well run
pipenv --rm
rm Pipfil*
The command deletes the virtualenv and then the Pipfile.
Another, newer way to do it is to set the env variable
PIPENV_NO_INHERIT
. Then Pipenv won't look in the parent directory.
Thanks! @halloleo
first I cd into the dir them I create the python version I want to use pipenv --python 3.x.x
them I activate the shell pipenv shell
and confirm the actual env is in the correct folder. Last I start installing all de devs I need
Most helpful comment
Another, newer way to do it is to set the env variable
PIPENV_NO_INHERIT
. Then Pipenv won't look in the parent directory.