1
votes

I am new to pipenv so there might be something I'm not understanding here. However it seems like the virtual environment which is created depends on the current directory, which seems bad to me.

Here is what I did:

  1. Checked out code from Github which already had Pipfile and Pipfile.lock

  2. Did some unrelated stuff... at this point I was in a directory called /home/user/me/miniconda3/bin/

  3. Ran /home/user/me/miniconda3/bin/pipenv run python /home/user/me/my-script-dir/my-script.py

  4. This caused Pipenv to create a virtual environment. Output:

    Creating a virtualenv for this project... Using /home/user/me/miniconda3/bin/python (3.6.4) to create virtualenv… Already using interpreter /home/user/me/miniconda3/bin/python Using base prefix '/home/user/me/miniconda3' New python executable in /home/user/me/.local/share/virtualenvs/bin-YnM8YhRk/bin/python Installing setuptools, pip, wheel...done.

    Virtualenv location: /home/user/me/.local/share/virtualenvs/bin-YnM8YhRk Creating a Pipfile for this project…

  5. Then I realized that I needed to run pipenv install so this time I cd'd to the directory where the script is actually stored, /home/user/me/my-script-dir/, and ran /home/user/me/miniconda3/bin/pipenv install. Then I got this output:

    Creating a virtualenv for this project… Using /home/user/me/miniconda3/bin/python (3.6.4) to create virtualenv… Already using interpreter /home/user/me/miniconda3/bin/python Using base prefix '/home/user/me/miniconda3' New python executable in /home/user/me/.local/share/virtualenvs/my-script-dir-Ex37BY7g/bin/python Installing setuptools, pip, wheel...done.

    Virtualenv location: /home/user/me/.local/share/virtualenvs/my-script-dir-Ex37BY7g Installing dependencies from Pipfile.lock (6c24e4)…

So as you can see I actually was running the same script each time, but somehow it created two different virtual environments. And the virtual environments are named after what happened to be my current directory at the time, not the directory of the script. This seems like it would be very unwieldy unless I am missing something.

1
See stackoverflow.com/a/57171701/52817 to run the script without changing the current directorylaktak

1 Answers

1
votes

You are correct, the virtualenv Pipenv uses does depend on the current directory.