Error message
While using a conda environment and pre-commit
I receive the error:
error: Library stubs not installed for "requests" (or incompatible with Python 3.10)
The full error message is:
rc/export_data/plantuml_get_package.py:69: error: Library stubs not installed for "requests" (or incompatible with Python 3.10)
src/export_data/plantuml_get_package.py:69: note: Hint: "python3 -m pip install types-requests"
src/export_data/plantuml_get_package.py:69: note: (or run "mypy --install-types" to install all missing stub packages)
src/export_data/plantuml_get_package.py:69: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 24 source files)
The default solution is given in the error message:
mypy --install-types
However, the requirement is already satisfied:
Installing missing stub packages:
/usr/bin/python3 -m pip install types-requests
Install? [yN] y
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: types-requests in /usr/lib/python3/dist-packages (2.25)
Conda Yaml
This would suggest it may be installed on the device, but not in the conda environment, however, it should be, because the following conda environment is created successfully (last 2 lines):
# run: conda env create --file environment.yml
# include new packages: conda env update --file environment.yml
name: someenvironment
channels:
- conda-forge
- conda
dependencies:
# Specify specific python version.
- python=3.10
- anaconda
- nb_conda
- conda:
# Run python tests.
- pytest=6.1.2
# Convert notebooks to pdf.
- nbconvert
- matplotlib
# Support notebooks.
- nb_conda
# Visualise graphs for PlantUML
- graphviz
# Run graph software quickly
- networkx
- pip
- pip:
# Compile pdf from python.
- pdflatex
# Write unit tests on Jupyter notebooks.
- testbook
# Auto generate docstrings
- pyment
# Auto generate documentation.
- pdoc3
# Code formatting compliance
- black
# Generate diagrams.
- plantuml
# Identify and remove dead code.
- vulture
# Get PlantUML .jar file.
- requests
- types-requests
Question
So I was wondering, how can I ensure the mypy
recognizes the types-requests
package in the environment?