Starting django with python manage.py runserver and getting ModuleNotFoundError: No module named '_msi'

django was working fine my venv got corrupted and I rebuilt it from requirements.txt now getting File "C:\Users\PC\OneDrive\Documents\GitHub\DoseV3Master\venv\Lib\site-packages\msilib_init_.py", line 3, in from _msi import * ModuleNotFoundError: No module named '_msi'

went to pypi and got the installer pip install python-msi to noeffect. Then pip install pymsilib also no effect.

This is most likely due to msilib:

Creating venv using python <= 3.12 if you are on windows should solve the issue. On linux, you may have to choose alternative package. Assuming it was working for you earlier, its most likely 3.13 issue.

The _msi module is part of the Windows-specific Python standard library, but it's only included when Python is installed using the official Windows installer from python.org. If you installed Python from another source (e.g., via the Microsoft Store or a minimal installer), _msi may be missing.

1. Reinstall Python from the official source

  • Go to: https://www.python.org/downloads/windows/

  • Download the official installer for your Python version (e.g., 3.11.x)

  • During installation:

    • Select “Add Python to PATH

    • Choose "Customize installation" and make sure all optional features are selected

2. Recreate your virtual environment

After reinstalling Python:

# Delete the broken virtual environment 
rm -r venv  # or delete the folder manually on Windows  
# Recreate it 
python -m venv venv 
venv\Scripts\activate 
pip install -r requirements.txt 

Avoid installing python-msi or pymsilib via pip — they are not official and will not solve the issue.

The error occurs because your Python install is missing the _msi module. Reinstall Python using the official Windows installer from python.org, then recreate your virtual environment — this will restore _msi support.

Вернуться на верх