Python: Difference between revisions

Jump to navigation Jump to search
880 bytes added ,  3 months ago
Added ModuleNotFoundError troubleshooting section
(link was broken, seemed double "##" caused it. Removed one.)
(Added ModuleNotFoundError troubleshooting section)
Line 677: Line 677:
This can be solved by installing a previous version of numpy: <code>pip install --no-index 'numpy<1.24'</code>.
This can be solved by installing a previous version of numpy: <code>pip install --no-index 'numpy<1.24'</code>.


=== ModuleNotFoundError: No module named 'X' ===
When importing a Python module, it may not be found. Numerous reasons may explain this error but common cases are :
* the package is not installed or not visible by the python interpreter;
* not imported as it is named;
* a broken virtual environment.
In order to avoid these common cases, avoid:
* modifying <code>PYTHONPATH</code> environment variable;
* modifying <code>PATH</code> environment variable;
* loading a module with a virtual env. activated (which in turn modifies the priors)
To solve this, ensure that the above element did not interfere, then:
* that the package is installed and named correctly (upper or lower case and underscores matters); run <code>pip list</code>;
* that it is imported at the correct level (when importing from its source directory)
In doubt, start from zero in a clean new environment.
</translate>
</translate>
cc_staff
284

edits

Navigation menu