asdf-community / asdf-python

Python plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
643 stars 55 forks source link

Default packages fail to install if `PIP_REQUIRE_VIRTUALENV` is set #162

Open liamdawson opened 1 year ago

liamdawson commented 1 year ago

When installing a new Python version, it failed when attempting to install default packages:

Installed Python-3.11.4 to /Users/myusername/.asdf/installs/python/3.11.4

Installing default python packages...ERROR: Could not find an activated virtualenv (required).

This is because I have PIP_REQUIRE_VIRTUALENV set to true in my shell. Looking at the install command, it uses pip as such:

https://github.com/asdf-community/asdf-python/blob/8505457c6612514688ba473386d2063d4c83bb54/bin/install#L38

According to this Stack Overflow answer, I believe this command should include the --isolated flag. In my case, adding the flag works:

$ pip install -U -r ~/.default-python-packages
ERROR: Could not find an activated virtualenv (required).

$ pip install -U -r ~/.default-python-packages --isolated
Requirement already satisfied: ...