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_VENV_IN_PROJECT in .env file ignored during initial pipenv shell command

See original GitHub issue

Put the following line into the local .env file: export PIPENV_VENV_IN_PROJECT=1

Running pipenv shell creates a .venv in ~/.local..., not the .venv directory as expected. Running pipenv sync then creates the local .venv file, but the Python interpreter is not there.

I’ve done some debugging and found that when running the initial shell command, the os.environ commands in environment.py are run prior to core.load_dot_env. The Python globals containing the environment variables are not reloaded after the .env file is loaded.

Is there a reason the .env file is not loaded earlier?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
techalchemycommented, Jun 6, 2018

Have a look at tools like direnv if you want this to operate like this as well

1reaction
uranusjrcommented, Jun 6, 2018

.env is only read for shell and run. This is a design decision made early on, and likely won’t be changed without substential reasoning and convicing arguments (I know because I failed before). Sorry about this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage of Pipenv - Read the Docs
This causes Pipenv to ignore changes to the Pipfile and (more importantly) prevents it from adding the current environment to Pipfile. lock ....
Read more >
Manage the path to the venv for pipenv - Stack Overflow
Yes, it is possible by setting environment variables. You can set a path for virtual environments via the WORKON_HOME .
Read more >
Pipenv: Practical Guide to the New Python Packaging Tool
Pipenv is a tool that creates and manages a virtual environment for your projects and adds or removes packages from your Pipfile as...
Read more >
Pipenv Virtual Environments for Python - Blog Post
Below is a guide on how to activate your first pipenv . ... pipenv --python 3.7. Note: that python3 --V is a command...
Read more >
Python Virtual Environment with pipenv - YouTube
With help of Python pipenv it's very easy to create Python virtual environments. Also it helps to manage all dependency packages of your ......
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