Strange behaviour of subprocess_check_output with Macports Python in virtualenv
Ryan Schmidt
ryandesign at macports.org
Thu Mar 12 23:09:21 UTC 2020
I am dropping macports-dev from Cc because the question is not about developing MacPorts.
On Feb 7, 2020, at 18:42, Ruben Di Battista wrote:
> Hello,
> I’m experiencing a problem (https://github.com/davidhalter/jedi/issues/1375).
>
> Running this on a Python installed with Macports:
> ```
> Python 3.8.1 (default, Feb 8 2020, 01:33:23)
> [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import subprocess
> >>> subprocess.check_output('/Users/rubendibattista/.envs/josiepy-B4k-0ZyT/bin/python -c "import sys; print(sys.executable)"', shell=True)
> b'/opt/local/bin/python\n'
>
> ```
>
> I get as result the system python executable and not the one from the virtualenv (created using pew).
> While on Linux:
>
> ```
> Python 3.7.3 (default, Jun 7 2019, 17:57:55)
> [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import subprocess
> >>> subprocess.check_output('/home/ruben.di-battista/.envs/josiepy/bin/python -c "import sys; print(sys.executable)"', shell=True)
> b'/home/ruben.di-battista/.envs/josiepy/bin/python\n'
>
> ```
>
> Does it work for you? Is it a bug from Macports, from my particular configuration, from macOs or from Python build on macOs? (Or isn’t a bug?)
I am not very familiar with Python and I do not have any virtualenv. I can however offer this result from my High Sierra system:
$ /opt/local/bin/python3.8
Python 3.8.2 (default, Mar 2 2020, 03:10:15)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.check_output('/opt/local/bin/python3.7 -c "import sys; print(sys.executable)"', shell=True)
b'/opt/local/bin/python3.7\n'
>>> ^D
In other words, that seems to be working correctly.
Possibly relevant is that I do not have /opt/local/bin/python. If you have it, what is it, and do you still experience the same problem if you remove it?
More information about the macports-users
mailing list