gboeing / osmnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
https://osmnx.readthedocs.io
MIT License
4.91k stars 828 forks source link

How to solve ImportError: matplotlib must be installed as an optional dependency for visualization #1224

Closed JamesGavin1 closed 1 month ago

JamesGavin1 commented 1 month ago

Contributing guidelines

Documentation

Existing issues

What operating system and Python version are you using?

Windows 11 /Python 3.9.11

What OSMnx version are you using?

1.9.1

Environment packages and versions

# Name                    Version                   Build  Channel
absl-py                   2.1.0              pyhd8ed1ab_0    conda-forge
access                    1.1.9                    pypi_0    pypi
affine                    2.4.0              pyhd8ed1ab_0    conda-forge
alembic                   1.13.2                   pypi_0    pypi
anyio                     4.4.0                    pypi_0    pypi
appdirs                   1.4.4              pyhd3eb1b0_0    defaults
arcgis                    2.0.1                 py39_2825    esri
arcgispro                 3.0                           0    esri
arcpy                     3.0             py39_arcgispro_36045  [arcgispro]  esri
arrow-cpp                 1.0.1                        10    esri
asn1crypto                1.4.0                      py_0    defaults
astor                     0.8.1                    pypi_0    pypi
atomicwrites              1.4.0                      py_0    defaults
attrs                     23.2.0                   pypi_0    pypi
azure-core                1.12.0                     py_0    esri
azure-storage-blob        12.8.0                     py_0    esri
backcall                  0.2.0              pyhd3eb1b0_0    defaults
bayesian-optimization     1.5.0                    pypi_0    pypi
beautifulsoup4            4.12.3                   pypi_0    pypi
black                     22.1.0                   py39_3    esri
blas                      1.0                         mkl    defaults
bleach                    4.1.0              pyhd3eb1b0_0    defaults
blinker                   1.4              py39haa95532_0    defaults
bottleneck                1.3.4            py39h080aedc_0    defaults
branca                    0.7.1              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py39h2bbff1b_1003    defaults
bzip2                     1.0.8                hcfcfb64_5    conda-forge
c-ares                    1.28.1               hcfcfb64_0    conda-forge
ca-certificates           2024.6.2             h56e8100_0    conda-forge
cached-property           1.5.2                      py_0    defaults
cachetools                4.2.2              pyhd3eb1b0_0    defaults
catboost                  1.2.5                    pypi_0    pypi
certifi                   2024.6.2           pyhd8ed1ab_0    conda-forge
cffi                      1.15.0           py39h2bbff1b_1    defaults
cfitsio                   3.470                h0af3d06_7    conda-forge
cftime                    1.5.0                    py39_1    esri
chardet                   4.0.0           py39haa95532_1003    defaults
charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults
click                     8.0.4            py39haa95532_0    defaults
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
cloudpickle               3.0.0                    pypi_0    pypi
colorama                  0.4.6                    pypi_0    pypi
coloredlogs               15.0.1                   pypi_0    pypi
colorlog                  6.8.2                    pypi_0    pypi
contourpy                 1.2.1                    pypi_0    pypi
cppzmq                    4.4.1                         4    esri
cpuonly                   2.0                           0    pytorch
cryptography              42.0.5           py39hb6bd5e6_0    conda-forge
curl                      7.85.0               heaf79c2_0    conda-forge
cycler                    0.11.0             pyhd3eb1b0_0    defaults
decorator                 5.1.1              pyhd3eb1b0_0    defaults
defusedxml                0.7.1              pyhd3eb1b0_0    defaults
deprecation               2.1.0                    pypi_0    pypi
despatch                  0.2.0                    py39_0    esri
entrypoints               0.3              py39haa95532_0    defaults
esda                      2.5.1                    pypi_0    pypi
et_xmlfile                1.1.0            py39haa95532_0    defaults
exceptiongroup            1.2.1                    pypi_0    pypi
expat                     2.6.2                h63175ca_0    conda-forge
fastcache                 1.1.0            py39h196d8e1_0    defaults
filelock                  3.13.1           py39haa95532_0    defaults
fiona                     1.8.22           py39hac22706_0    defaults
flake8                    4.0.1              pyhd3eb1b0_1    defaults
flatbuffers               24.3.25                  pypi_0    pypi
folium                    0.16.0             pyhd8ed1ab_0    conda-forge
fonttools                 4.53.0                   pypi_0    pypi
freetype                  2.12.1                        0    esri
freexl                    1.0.6                h67ca5e6_1    conda-forge
fsspec                    2024.6.0                 pypi_0    pypi
future                    0.18.2                   py39_2    esri
gdal                      3.4.0           arcgispro_py39_17119  [arcgispro]  esri
geomet                    0.3.0                      py_1    esri
geopandas                 1.0.1                    pypi_0    pypi
geos                      3.8.0                he025d50_1    conda-forge
geotiff                   1.7.0                h4545760_0    defaults
giddy                     2.3.5                    pypi_0    pypi
grpcio                    1.62.2           py39hd28a505_0    conda-forge
h11                       0.14.0                   pypi_0    pypi
h5py                      3.6.0                    py39_4    esri
hdf4                      4.2.13            h0e5069d_1005    conda-forge
hdf5                      1.10.6          nompi_he0bbb20_101    conda-forge
hpsklearn                 0.1.0                    pypi_0    pypi
html5lib                  1.1                pyhd3eb1b0_0    defaults
httpcore                  1.0.5                    pypi_0    pypi
httpx                     0.27.0                   pypi_0    pypi
humanfriendly             10.0                     pypi_0    pypi
hyperopt                  0.2.5                    pypi_0    pypi
icc_rt                    2019.0.5            arcgispro_0  [arcgispro]  esri
idna                      3.3                pyhd3eb1b0_0    defaults
igraph                    0.11.4                   pypi_0    pypi
imageio                   2.35.1                   pypi_0    pypi
importlib-metadata        4.11.3           py39haa95532_0    defaults
importlib-resources       6.4.0                    pypi_0    pypi
importlib_metadata        4.11.3               hd3eb1b0_0    defaults
inequality                1.0.0                    pypi_0    pypi
iniconfig                 1.1.1              pyhd3eb1b0_0    defaults
intel-openmp              2020.0            arcgispro_166  [arcgispro]  esri
ipykernel                 5.3.4            py39h7b7c402_0    defaults
ipython                   7.21.0                   py39_2    esri
ipython_genutils          0.2.0              pyhd3eb1b0_1    defaults
ipywidgets                7.6.5                      py_0    esri
isodate                   0.6.0                      py_0    esri
jdcal                     1.4.1              pyhd3eb1b0_0    defaults
jedi                      0.18.0                   py39_0    esri
jinja2                    3.0.3              pyhd3eb1b0_0    defaults
joblib                    1.3.2              pyhd8ed1ab_0    conda-forge
jpeg                      9d                            0    esri
json5                     0.9.5                      py_0    esri
jsonschema                3.2.0              pyhd3eb1b0_2    defaults
jupyter_client            6.1.7                      py_1    esri
jupyter_console           6.4.0                      py_1    esri
jupyter_contrib_core      0.3.3                      py_4    esri
jupyter_contrib_nbextensions 0.5.1                     py_24    esri
jupyter_core              4.6.3                    py39_2    esri
jupyter_highlight_selected_word 0.2.0                      py_4    esri
jupyter_latex_envs        1.4.6                      py_3    esri
jupyter_nbextensions_configurator 0.4.1                      py_3    esri
jupyterlab                2.2.10                     py_0    esri
jupyterlab_server         1.2.0                      py_0    defaults
jupyterlab_widgets        1.0.0              pyhd3eb1b0_1    defaults
kealib                    1.4.14               h96bfa42_2    conda-forge
keplergl                  0.3.2              pyhd8ed1ab_0    conda-forge
keyring                   23.4.0                   py39_0    esri
kiwisolver                1.3.2            py39hd77b12b_0    defaults
krb5                      1.19.3               hc8ab02b_0    conda-forge
lerc                      3.0                pyh39e3cac_0    esri
leuvenmapmatching         1.1.4                    pypi_0    pypi
libabseil                 20240116.2      cxx17_h63175ca_0    conda-forge
libblas                   3.9.0           1_h8933c1f_netlib    conda-forge
libcblas                  3.9.0           5_hd5c7e75_netlib    conda-forge
libcurl                   7.85.0               heaf79c2_0    conda-forge
libdeflate                1.8                  h2bbff1b_5    defaults
libexpat                  2.6.2                h63175ca_0    conda-forge
libgdal                   3.0.2                h3d7c30d_2    defaults
libgrpc                   1.62.2               h5273850_0    conda-forge
libiconv                  1.17                 hcfcfb64_2    conda-forge
libjpeg-turbo             2.0.0                h196d8e1_0    defaults
libnetcdf                 4.8.1                h6685c40_1    defaults
libpng                    1.6.37               h2a8f88b_0    defaults
libpq                     12.9                 hb652d5d_3    defaults
libprotobuf               4.25.3               h503648d_0    conda-forge
libpysal                  4.8.1                    pypi_0    pypi
libre2-11                 2023.09.01           hf8d8778_2    conda-forge
libsodium                 1.0.18                        2    esri
libspatialindex           1.9.3                h39d44d4_4    conda-forge
libspatialite             4.3.0a            he9c6e69_1033    conda-forge
libssh2                   1.10.0               h9a1e1f7_3    conda-forge
libtiff                   4.3.0                         1    esri
libuv                     1.44.2               h2bbff1b_0    defaults
libxml2                   2.9.12              arcgispro_0  [arcgispro]  esri
libxslt                   1.1.34               he774522_0    defaults
libzip                    1.9.2                h519de47_1    conda-forge
libzlib                   1.2.13               h2466b09_6    conda-forge
lightgbm                  4.4.0                    pypi_0    pypi
llvmlite                  0.42.0                   pypi_0    pypi
lxml                      4.8.0            py39h1985fb9_0    defaults
lz4-c                     1.9.3                h2bbff1b_1    defaults
m2w64-expat               2.1.1                         2    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gettext             0.19.7                        2    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libiconv            1.14                          6    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
m2w64-xz                  5.2.2                         2    conda-forge
mako                      1.3.5                    pypi_0    pypi
mapclassify               2.5.0              pyhd8ed1ab_1    conda-forge
markdown                  3.6                pyhd8ed1ab_0    conda-forge
markupsafe                2.0.1            py39h2bbff1b_0    defaults
matplotlib                3.3.0                    pypi_0    pypi
matplotlib-inline         0.1.6                    pypi_0    pypi
mccabe                    0.7.0              pyhd3eb1b0_0    defaults
mgwr                      2.2.1                    pypi_0    pypi
mistune                   0.8.4           py39h2bbff1b_1000    defaults
mkl                       2020.0            arcgispro_167  [arcgispro]  esri
mkl-service               2.3.0                    py39_2    esri
mkl_fft                   1.3.0                    py39_0    esri
mkl_random                1.2.2                    py39_0    esri
momepy                    0.6.0                    pypi_0    pypi
mpmath                    1.2.1            py39haa95532_0    defaults
msrest                    0.6.21                     py_0    esri
msys2-conda-epoch         20160418                      1    conda-forge
munch                     4.0.0              pyhd8ed1ab_0    conda-forge
mypy_extensions           0.4.3            py39haa95532_1    defaults
nbconvert                 5.6.1                    py39_1    esri
nbformat                  5.1.3                      py_1    esri
netcdf4                   1.5.7           py39_arcgispro_3  [arcgispro]  esri
networkx                  2.7.1              pyhd3eb1b0_0    defaults
nlohmann_json             3.7.0                         2    esri
nose                      1.3.7           pyhd3eb1b0_1008    defaults
notebook                  5.7.10                   py39_1    esri
ntlm-auth                 1.4.0                      py_0    esri
numba                     0.59.1                   pypi_0    pypi
numexpr                   2.8.1                    py39_0    esri
numpy                     1.26.4                   pypi_0    pypi
oauthlib                  3.2.0                    py39_0    esri
olefile                   0.46               pyhd3eb1b0_0    defaults
onnx                      1.16.1                   pypi_0    pypi
onnxruntime               1.18.0                   pypi_0    pypi
opencv-python             4.10.0.82                pypi_0    pypi
openjpeg                  2.5.0                hb211442_0    conda-forge
openpyxl                  3.1.5                    pypi_0    pypi
openssl                   3.3.1                h2466b09_0    conda-forge
opt-einsum                3.3.0                    pypi_0    pypi
optuna                    3.6.1                    pypi_0    pypi
optuna-integration        3.6.0                    pypi_0    pypi
outcome                   1.3.0.post0              pypi_0    pypi
packaging                 21.3               pyhd3eb1b0_0    defaults
paddlepaddle              2.6.1                    pypi_0    pypi
pandas                    2.2.2                    pypi_0    pypi
pandoc                    2.3                      pypi_0    pypi
pandocfilters             1.5.0              pyhd3eb1b0_0    defaults
parso                     0.8.3              pyhd3eb1b0_0    defaults
pathspec                  0.9.0                      py_0    esri
patsy                     0.5.6                    pypi_0    pypi
pefile                    2019.4.18                  py_0    defaults
pickleshare               0.7.5           pyhd3eb1b0_1003    defaults
pillow                    9.1.0                    py39_3    esri
pip                       24.2                     pypi_0    pypi
platformdirs              2.4.0              pyhd3eb1b0_0    defaults
plotly                    5.23.0                   pypi_0    pypi
pluggy                    0.13.1           py39haa95532_0    defaults
plumbum                   1.8.3                    pypi_0    pypi
ply                       3.11                     pypi_0    pypi
pointpats                 2.4.0                    pypi_0    pypi
pro_notebook_integration  3.0                      py39_1    esri
proj                      6.2.1                ha7a8c7b_0    conda-forge
prometheus_client         0.8.0                      py_0    esri
prompt_toolkit            3.0.5                      py_0    esri
protobuf                  3.20.2                   pypi_0    pypi
psutil                    5.8.0            py39h2bbff1b_1    defaults
pulp                      2.8.0                    pypi_0    pypi
py                        1.11.0             pyhd3eb1b0_0    defaults
py-cpuinfo                9.0.0                    pypi_0    pypi
py4j                      0.10.9.7                 pypi_0    pypi
pyaml                     24.4.0                   pypi_0    pypi
pyarrow                   1.0.1                    py39_3    esri
pybind11                  2.7.1                         0    esri
pybind11_json             0.2.6                         3    esri
pycairo                   1.26.0                   pypi_0    pypi
pycodestyle               2.8.0              pyhd3eb1b0_0    defaults
pycparser                 2.21               pyhd3eb1b0_0    defaults
pyflakes                  2.4.0              pyhd3eb1b0_0    defaults
pygments                  2.9.0                      py_0    esri
pyhtml2pdf                0.0.7                    pypi_0    pypi
pyjwt                     2.4.0                      py_1    esri
pykalman                  0.9.5                      py_1    conda-forge
pyodbc                    4.0.32           py39hd77b12b_1    defaults
pyogrio                   0.10.0                   pypi_0    pypi
pyopenssl                 24.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.4              pyhd3eb1b0_0    defaults
pypdf2                    1.26.0                     py_4    esri
pyproj                    3.6.1                    pypi_0    pypi
pyreadline3               3.4.1                    pypi_0    pypi
pyrsistent                0.18.0           py39h196d8e1_0    defaults
pysal                     24.1                     pypi_0    pypi
pyshp                     2.1.3              pyhd3eb1b0_0    defaults
pysocks                   1.7.1            py39haa95532_0    defaults
pytest                    6.2.4                    py39_0    esri
python                    3.9.11                        3    esri
python-certifi-win32      1.6                        py_0    esri
python-dateutil           2.8.2              pyhd3eb1b0_0    defaults
python-dotenv             1.0.1                    pypi_0    pypi
python-graphviz           0.20.3                   pypi_0    pypi
python-louvain            0.15               pyhd3eb1b0_0    defaults
python_abi                3.9                      1_cp39    esri
pytorch                   2.2.2               py3.9_cpu_0    pytorch
pytorch-mutex             1.0                         cpu    pytorch
pytz                      2022.1                   py39_0    esri
pywin32                   306                      pypi_0    pypi
pywin32-ctypes            0.2.0                    py39_0    esri
pywin32-security          302                      py39_1    esri
pywinpty                  2.0.1                    py39_0    esri
pyyaml                    6.0              py39h2bbff1b_1    defaults
pyzmq                     19.0.2                   pypi_0    pypi
quantecon                 0.7.2                    pypi_0    pypi
rasterio                  1.2.10           py39h17c1fa0_0    defaults
rasterstats               0.19.0                   pypi_0    pypi
re2                       2023.09.01           hd3b24a8_2    conda-forge
regex                     2022.3.15        py39h2bbff1b_0    defaults
requests                  2.27.1             pyhd3eb1b0_0    defaults
requests-kerberos         0.12.0                        0    esri
requests-negotiate-sspi   0.5.3                    py39_0    esri
requests-oauthlib         1.3.0                      py_0    defaults
requests-toolbelt         0.9.1              pyhd3eb1b0_0    defaults
requests_ntlm             1.1.0                      py_0    esri
rtree                     1.2.0            py39h09fdee3_0    conda-forge
saspy                     3.7.8                      py_0    esri
scikit-learn              1.1.2            py39hfd4428b_0    conda-forge
scikit-optimize           0.10.2                   pypi_0    pypi
scipy                     1.13.0                   pypi_0    pypi
seaborn                   0.12.2           py39haa95532_0    defaults
segregation               2.5                      pypi_0    pypi
selenium                  4.22.0                   pypi_0    pypi
send2trash                1.8.0              pyhd3eb1b0_1    defaults
setuptools                60.10.0                  py39_0    esri
setuptools-scm            8.1.0                    pypi_0    pypi
shapely                   2.0.1            py39hd7f5953_0    defaults
simplegeneric             0.8.1            py39haa95532_2    defaults
simplejson                3.19.2                   pypi_0    pypi
six                       1.16.0                     py_0    esri
smopy                     0.0.8                    pypi_0    pypi
sniffio                   1.3.1                    pypi_0    pypi
snuggs                    1.4.7                      py_0    conda-forge
sortedcontainers          2.4.0                    pypi_0    pypi
soupsieve                 2.5                      pypi_0    pypi
spaghetti                 1.7.4                    pypi_0    pypi
spglm                     1.1.0                    pypi_0    pypi
spint                     1.0.7                    pypi_0    pypi
splot                     1.1.5.post1              pypi_0    pypi
spopt                     0.5.0                    pypi_0    pypi
spreg                     1.4.2                    pypi_0    pypi
spvcm                     0.3.0                    pypi_0    pypi
sqlalchemy                1.3.12           py39h196d8e1_0    defaults
sqlite                    3.38.2                        0    esri
statsmodels               0.14.2                   pypi_0    pypi
swat                      1.9.3                    py39_0    esri
sympy                     1.9                      py39_1    esri
tenacity                  8.5.0                    pypi_0    pypi
tensorboard               2.17.0             pyhd8ed1ab_0    conda-forge
tensorboard-data-server   0.7.0            py39hcbf5309_1    conda-forge
terminado                 0.13.1           py39haa95532_0    defaults
testpath                  0.5.0                      py_0    esri
texttable                 1.7.0                    pypi_0    pypi
threadpoolctl             3.4.0              pyhc1e730c_0    conda-forge
tiledb                    2.2.9                hf84e3da_0    conda-forge
tobler                    0.11.2                   pypi_0    pypi
toml                      0.10.2             pyhd3eb1b0_0    defaults
tomli                     1.2.2              pyhd3eb1b0_0    defaults
torchaudio                2.2.2                  py39_cpu    pytorch
torchvision               0.17.2                 py39_cpu    pytorch
tornado                   6.1              py39h2bbff1b_0    defaults
tqdm                      4.66.2                   pypi_0    pypi
traitlets                 5.1.1              pyhd3eb1b0_0    defaults
traittypes                0.2.1            py39haa95532_0    defaults
transbigdata              0.5.3              pyhd8ed1ab_0    conda-forge
trio                      0.26.0                   pypi_0    pypi
trio-websocket            0.11.1                   pypi_0    pypi
typed-ast                 1.4.3            py39h2bbff1b_1    defaults
typing-extensions         4.12.2                   pypi_0    pypi
tzdata                    2024.1                   pypi_0    pypi
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
ujson                     5.1.0            py39hd77b12b_0    defaults
ultralytics               8.2.29                   pypi_0    pypi
ultralytics-thop          0.2.7                    pypi_0    pypi
urllib3                   1.26.8             pyhd3eb1b0_0    defaults
vc                        14.2                 h21ff451_1    defaults
vc14_runtime              14.38.33130         h82b7239_18    conda-forge
vincenty                  0.1.4                    pypi_0    pypi
vs2015_runtime            14.38.33130         hcb4865c_18    conda-forge
wcwidth                   0.2.5              pyhd3eb1b0_0    defaults
webdriver-manager         4.0.1                    pypi_0    pypi
webencodings              0.5.1            py39haa95532_1    defaults
websocket-client          1.8.0                    pypi_0    pypi
werkzeug                  2.1.2              pyhd8ed1ab_1    conda-forge
wheel                     0.37.1             pyhd3eb1b0_0    defaults
widgetsnbextension        3.5.2            py39haa95532_0    defaults
win_inet_pton             1.1.0                    py39_0    esri
wincertstore              0.2              py39haa95532_2    defaults
winkerberos               0.8.0                    py39_0    esri
winpty                    0.4.3                         4    defaults
wrapt                     1.13.3           py39h2bbff1b_2    defaults
wsproto                   1.2.0                    pypi_0    pypi
x86cpu                    0.4                      py39_1    esri
xarray                    0.20.1             pyhd3eb1b0_1    defaults
xerces-c                  3.2.5                h63175ca_0    conda-forge
xeus                      0.24.1                        8    esri
xeus-python               0.8.2                        10    esri
xgboost                   2.1.0                    pypi_0    pypi
xlrd                      2.0.1              pyhd3eb1b0_0    defaults
xlwt                      1.3.0            py39haa95532_0    defaults
xtl                       0.6.15                        1    esri
xyzservices               2023.10.1          pyhd8ed1ab_0    conda-forge
xz                        5.2.5                h8cc25b3_1    defaults
yaml                      0.2.5                         0    esri
zeromq                    4.3.4                         0    esri
zipp                      3.7.0              pyhd3eb1b0_0    defaults
zlib                      1.2.13               h2466b09_6    conda-forge
zlib-ng                   2.0.5                         0    esri
zstd                      1.4.9                h19a0ad4_0    defaults

How did you install OSMnx?

Pip

Problem description

import networkx as nx import osmnx as ox import matplotlib.pyplot as plt import matplotlib bounds = [114.05, 22.55, 114.07, 22.57] north, south, east, west = bounds[3], bounds[1], bounds[2], bounds[0] G = ox.graph_from_bbox(north, south, east, west, network_type='drive') ox.plot_graph(G) ImportError: matplotlib must be installed as an optional dependency for visualization I have matplotlib but I can't cite it.How to solve this problem.

Complete minimal reproducible example

import networkx as nx
import osmnx as ox
import matplotlib.pyplot as plt
import matplotlib
bounds = [114.05, 22.55, 114.07, 22.57] 
north, south, east, west = bounds[3], bounds[1], bounds[2], bounds[0] 
G = ox.graph_from_bbox(north, south, east, west, network_type='drive')
ox.plot_graph(G)
gboeing commented 1 month ago

You can solve this problem by following the installation instructions.

Looking through the environment packages you pasted, you can see OSMnx isn't there.