Pip version:
$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
Python version:
$ python --version
Python 2.7.14
$ which python
/usr/local/opt/python@2/libexec/bin/python
Operating system: macOS 10.13.3
Description:
This morning, when I ran virtualenv, I got this:
$ virtualenv
-bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
virtualenv only started behaving this way today. It worked yesterday. It broke because virtualenv is a Python script which embeds the absolute path to a Python interpreter which went away:
$ which virtualenv
/usr/local/bin/virtualenv
$ head -1 /usr/local/bin/virtualenv
#!/usr/local/opt/python/bin/python2.7
It appears that this absolute path is generated dynamically! After pip uninstall virtualenv && pipinstall virtualenv, I get a new absolute path to a new Python interpreter:
$ head -1 /usr/local/bin/virtualenv
#!/usr/local/opt/python@2/bin/python2.7
This behavior is not idiomatic, and causes pip-installed packages to break in confusing ways when the path to the interpreter changes!
The idiomatic behavior is for virtualenv to resolve Python from my PATH at runtime, not at install time. For example, the script could begin with a portable interpreter command, e.g. #!/usr/bin/env python. Why is this not the case?
Pip version:
Python version:
Operating system: macOS 10.13.3
Description:
This morning, when I ran
virtualenv, I got this:virtualenvonly started behaving this way today. It worked yesterday. It broke becausevirtualenvis a Python script which embeds the absolute path to a Python interpreter which went away:It appears that this absolute path is generated dynamically! After
pip uninstall virtualenv && pipinstall virtualenv, I get a new absolute path to a new Python interpreter:This behavior is not idiomatic, and causes pip-installed packages to break in confusing ways when the path to the interpreter changes!
The idiomatic behavior is for
virtualenvto resolve Python from myPATHat runtime, not at install time. For example, the script could begin with a portable interpreter command, e.g.#!/usr/bin/env python. Why is this not the case?