Python: Difference between revisions

Jump to navigation Jump to search
52 bytes added ,  3 months ago
Marked this version for translation
(Added ModuleNotFoundError troubleshooting section)
(Marked this version for translation)
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' ===
=== ModuleNotFoundError: No module named 'X' === <!--T:115-->
When importing a Python module, it may not be found. Numerous reasons may explain this error but common cases are :
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;
* the package is not installed or not visible by the python interpreter;
Line 683: Line 683:
* a broken virtual environment.
* a broken virtual environment.


<!--T:116-->
In order to avoid these common cases, avoid:
In order to avoid these common cases, avoid:
* modifying <code>PYTHONPATH</code> environment variable;
* modifying <code>PYTHONPATH</code> environment variable;
Line 688: Line 689:
* loading a module with a virtual env. activated (which in turn modifies the priors)
* loading a module with a virtual env. activated (which in turn modifies the priors)


<!--T:117-->
To solve this, ensure that the above element did not interfere, then:
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 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)
* that it is imported at the correct level (when importing from its source directory)


<!--T:118-->
In doubt, start from zero in a clean new environment.
In doubt, start from zero in a clean new environment.
</translate>
</translate>
cc_staff
284

edits

Navigation menu