Question: Python script fails with ModuleNotFoundError: No module named 'msal' — recommended way to declare MSAL dependency?
Description
I’m running a Python script that imports the Microsoft Authentication Library for Python (msal) at startup. When executed in a clean virtual environment, the script fails immediately with a ModuleNotFoundError because msal is not installed automatically.
I’d like to confirm the recommended and supported way to declare and install the MSAL dependency so that users don’t encounter a runtime crash.
Error
Traceback (most recent call last):
File "/home/learnadmin/xss.py", line 65, in <module>
import msal
ModuleNotFoundError: No module named 'msal'
Environment
OS: Linux
Python version: 3.x
pip: latest
Virtual environment: yes
Steps to reproduce
git clone <REPO_URL>
cd <REPO_DIR>
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 xss.py
Expected behavior
One of the following:
msal is installed automatically as a dependency, or
Documentation clearly states that msal must be installed manually, or
The script exits with a helpful message explaining the missing dependency.
Actual behavior
The script crashes immediately with:
ModuleNotFoundError: No module named 'msal'
Workaround
Manually installing MSAL resolves the issue:
python3 -m pip install msal
Questions
Is msal intended to be a mandatory dependency for scripts that use Microsoft identity authentication flows?
What is the recommended way to declare this dependency for Python users (for example, requirements.txt vs pyproject.toml)?
Is there a preferred pattern for gracefully handling a missing msal dependency at runtime?
Additional context
The script imports msal directly without guarding the import or documenting it as a required dependency. Clarifying the expected setup would make onboarding and testing smoother for new users.
Thanks in advance for any guidance.
Question: Python script fails with ModuleNotFoundError: No module named 'msal' — recommended way to declare MSAL dependency?
Description
I’m running a Python script that imports the Microsoft Authentication Library for Python (msal) at startup. When executed in a clean virtual environment, the script fails immediately with a ModuleNotFoundError because msal is not installed automatically.
I’d like to confirm the recommended and supported way to declare and install the MSAL dependency so that users don’t encounter a runtime crash.
Error
Traceback (most recent call last):
File "/home/learnadmin/xss.py", line 65, in <module>
import msal
ModuleNotFoundError: No module named 'msal'
Environment
OS: Linux
Python version: 3.x
pip: latest
Virtual environment: yes
Steps to reproduce
git clone <REPO_URL>
cd <REPO_DIR>
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 xss.py
Expected behavior
One of the following:
msal is installed automatically as a dependency, or
Documentation clearly states that msal must be installed manually, or
The script exits with a helpful message explaining the missing dependency.
Actual behavior
The script crashes immediately with:
ModuleNotFoundError: No module named 'msal'
Workaround
Manually installing MSAL resolves the issue:
python3 -m pip install msal
Questions
Is msal intended to be a mandatory dependency for scripts that use Microsoft identity authentication flows?
What is the recommended way to declare this dependency for Python users (for example, requirements.txt vs pyproject.toml)?
Is there a preferred pattern for gracefully handling a missing msal dependency at runtime?
Additional context
The script imports msal directly without guarding the import or documenting it as a required dependency. Clarifying the expected setup would make onboarding and testing smoother for new users.
Thanks in advance for any guidance.