-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conda commands as Python3 subprocesses inside a virtualenv fail under macOS #1704
Comments
@nsoranzo does the same happen within a venv, or only virtualenv is affected by this? |
@gaborbernat It seems that venv is affected on macOS but not on Linux, as virtualenv: https://travis-ci.org/nsoranzo/bioblend/builds/660579284 |
@nsoranzo, in this case, this becomes either a conda or CPython venv module upstream bug, did you open tickets there? A side effect of virtualenv moving to the venv style virtual environments is that users now tend to discover all the venv bugs here 🤷♂ |
Thanks for the fast response! No, I did not open an upstream issue yet, I didn't know it was a venv bug till now! (I don't think it's conda's, given it works fine on Linux and with old virtualenv). I have feeling the issue could get more attention if you open it, but happy to do it myself if you prefer (Should this go on https://bugs.python.org/ ?). |
Unless I'm missing something, the issue seems to be that the conda command expects to be able to import conda in the active Python, but conda (the library) isn't installed in the active venv, so it can't. The fix is likely to be for the conda script to use a specific Python binary, not just pick up whatever is first on Edit: My mistake, the conda script has a shebang: #!/Users/travis/miniconda3/bin/python
# -*- coding: utf-8 -*-
import sys
# Before any more imports, leave cwd out of sys.path for internal 'conda shell.*' commands.
# see https://github.com/conda/conda/issues/6549
if len(sys.argv) > 1 and sys.argv[1].startswith('shell.') and sys.path and sys.path[0] == '':
# The standard first entry in sys.path is an empty string,
# and os.path.abspath('') expands to os.getcwd().
del sys.path[0]
if __name__ == '__main__':
from conda.cli import main
sys.exit(main()) So it should be getting run by the right interpreter. Sorry for the noise 🙁 |
Yeah needs to go on bugs.python.org; have a feeling this could be related to python/cpython#9516 🤷♂ |
@pfmoore Yep, I was going to point out that I checked that in https://travis-ci.org/nsoranzo/bioblend/jobs/660579286#L182 (and the conda lib is indeed installed in |
Note it could be a conda bug too, hence why saying that could be worthwhile open a bug first there. |
I'll close the issue for now. Please post here the upstream bug report links, so if other people run into it they can be redirected. If anything actionable comes out of those I'll reopen and make the changes. |
@gaborbernat I can confirm this is indeed due to python/cpython#9516 , see https://travis-ci.org/github/nsoranzo/bioblend/jobs/665637175 where deleting Now that python/cpython#9516 has been merged, would you consider patching virtualenv to remove |
We could patch it via the |
I think: <=3.7.7 or (>=3.8 and <=3.8.2) |
I prefer to have the customization only active when needed, instead of always on and guarded. Let's not have redundant generated code. |
Sure! |
Issue
Describe what's the expected behaviour and what you're observing.
Running any conda command as a Python3 subprocess inside of a virtualenv fails under macOS with
ModuleNotFoundError: No module named 'conda'
. This works fine under Linux or when using Python2 or virtualenv <20.The same works fine also before activating and after deactivating the virtualenv.
Tested on the latest virtualenv 20.0.9.
See https://travis-ci.org/nsoranzo/bioblend/builds/660456892 for how to reproduce on TravisCI and example of success and failure of the same commands under Linux and macOS respectively.
Environment
Provide at least:
OS: macOS
pip list
of the host python wherevirtualenv
is installed:Output of the virtual environment creation
Make sure to run the creation with
-vvv --with-traceback
:The text was updated successfully, but these errors were encountered: