This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ModuleNotFoundEror thrown by system python while accessing it specifically via venv python
Type: behavior Stage:
Components: macOS Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gavin, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2020-04-13 10:46 by gavin, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg366299 - (view) Author: Gavin D'souza (gavin) Date: 2020-04-13 10:46
I have a tool that works as a wrapper over a web framework which in turn utilizes a virtualenv environment. So every app to be installed for a project is installed in it's own env folder. 

Recently, the virtualenv has been breaking throwing 'ModuleNotFoundError's however this issue only persists in macOS. The applications installed in each project's env are editable installs. The ModuleNotFoundError's are raised by the global python install which is all the more confusing as the commands are specifically executing using absolute paths in the env python and should be in the env site-packages. Even after successful env installs, activating the env and simply typing "import frappe" throws a ModuleNotFoundError. 

Reference commands executed by the wrapper program are like
./env/bin/python -m install -q -U -e ./apps/frappe

have also tried absolute paths but faced the same issue. However, this issue doesn't persist while using pyenv on macOS. Linux systems work fine too.
msg367401 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-04-27 06:25
Without more information, in particular, a reproducible test case, we can only speculate what might be going on.  Suggest you try using some of the debugging tools Python includes, starting with invoking your virtualenv python with the -vv flag. As described here (https://docs.python.org/3/using/cmdline.html#id4) that should show what files are being searched when you attempt to do the failing import.  You should also try looking at the results of invoking that python with -m test.pythoninfo and examining the values of sys.path and any PYTHON* environment variables. If the problem persists, copy the results here. Good luck! (Note that Python 2.7 has reached end-of-life and is no longer supported here.)
msg367403 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-04-27 07:03
One additional thought: there was a longstanding issue specific to using venv on macOS that has recently been fixed (Issue22490); that fix will be released first in Python 3.8.3 which should be available in a few weeks (or, if you are comfortable doing so, you could build it yourself from the current 3.8 branch on Github). If the problem isn't solved otherwise, you could try to see if that fix in 3.8.3 helps.
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84453
2020-04-27 07:03:04ned.deilysetmessages: + msg367403
2020-04-27 06:25:09ned.deilysetmessages: + msg367401
versions: - Python 2.7
2020-04-13 10:46:31gavincreate