conda-forge / osmnx-feedstock

A conda-smithy repository for osmnx.
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

Cannot import osmnx when I using VS Code #77

Closed zyforcode closed 3 years ago

zyforcode commented 3 years ago

Issue: I have installed the OSMNX according to documentation on readthedocs, but I can't import osmnx when I using VS Code, here is the issues:

Traceback (most recent call last): File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\numpy\core__init__.py", line 22, in
from . import multiarray File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\numpy\core\multiarray.py", line 12, in from . import overrides File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\numpy\core\overrides.py", line 7, in
from numpy.core._multiarray_umath import ( ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "e:\VS Code WorkSpace\osmnx-examples\myfiles\learn_osmnx.py", line 2, in import osmnx as ox File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\osmnx__init.py", line 3, in from ._api import * File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\osmnx_api.py", line 3, in from .bearing import add_edge_bearings File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\osmnx\bearing.py", line 5, in import numpy as np File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\numpy\init.py", line 140, in from . import core File "D:\ProgramFilesTS\Anaconda3\envs\ox\lib\site-packages\numpy\core\init__.py", line 48, in raise ImportError(msg) ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: 找不到指定的模块。
Environment (conda list):

``` $ conda list # packages in environment at D:\ProgramFilesTS\Anaconda3\envs\ox: # # Name Version Build Channel anyio 2.0.2 py39hcbf5309_4 conda-forge argon2-cffi 20.1.0 py39hb82d6ee_2 conda-forge astroid 2.4.2 py39hde42818_1 conda-forge async_generator 1.10 py_0 conda-forge attrs 20.3.0 pyhd3deb0d_0 conda-forge babel 2.9.0 pyhd3deb0d_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.1 py_0 conda-forge bleach 3.2.1 pyh9f0ad1d_0 conda-forge boost-cpp 1.74.0 h54f0996_1 conda-forge branca 0.4.2 pyhd8ed1ab_0 conda-forge brotlipy 0.7.0 py39hb82d6ee_1001 conda-forge bzip2 1.0.8 h8ffe710_4 conda-forge ca-certificates 2020.12.5 h5b45459_0 conda-forge cairo 1.16.0 hd28d34b_1006 conda-forge certifi 2020.12.5 py39hcbf5309_1 conda-forge cffi 1.14.4 py39h0878f49_1 conda-forge cfitsio 3.470 h0af3d06_7 conda-forge chardet 4.0.0 py39hcbf5309_1 conda-forge click 7.1.2 pyh9f0ad1d_0 conda-forge click-plugins 1.1.1 py_0 conda-forge cligj 0.7.1 pyhd8ed1ab_0 conda-forge colorama 0.4.4 pyh9f0ad1d_0 conda-forge cryptography 3.3.1 py39h0878f49_1 conda-forge curl 7.71.1 h4b64cdc_8 conda-forge cycler 0.10.0 py_2 conda-forge decorator 4.4.2 py_0 conda-forge defusedxml 0.6.0 py_0 conda-forge descartes 1.1.0 py_4 conda-forge entrypoints 0.3 pyhd8ed1ab_1003 conda-forge expat 2.2.9 h33f27b4_2 conda-forge fiona 1.8.18 py39he2373ac_0 conda-forge folium 0.12.0 pyhd8ed1ab_0 conda-forge fontconfig 2.13.1 h1989441_1004 conda-forge freetype 2.10.4 h546665d_1 conda-forge freexl 1.0.5 hd288d7e_1002 conda-forge gdal 3.1.4 py39hda8168b_0 conda-forge geopandas 0.8.1 py_0 conda-forge geos 3.8.1 he025d50_0 conda-forge geotiff 1.6.0 h8884d1a_3 conda-forge gettext 0.19.8.1 h1a89ca6_1005 conda-forge glib 2.66.4 he2d232f_1 conda-forge hdf4 4.2.13 h0e5069d_1004 conda-forge hdf5 1.10.6 nompi_h5268f04_1114 conda-forge icu 67.1 h33f27b4_0 conda-forge idna 2.10 pyh9f0ad1d_0 conda-forge importlib-metadata 3.4.0 py39hcbf5309_0 conda-forge importlib_metadata 3.4.0 hd8ed1ab_0 conda-forge intel-openmp 2020.3 h57928b3_311 conda-forge ipykernel 5.4.2 py39he1a07ef_0 conda-forge ipython 7.18.1 py39h9cd51e4_1 conda-forge ipython_genutils 0.2.0 py_1 conda-forge isort 5.7.0 pyhd8ed1ab_0 conda-forge jedi 0.18.0 py39hcbf5309_2 conda-forge jinja2 2.11.2 pyh9f0ad1d_0 conda-forge joblib 1.0.0 pyhd8ed1ab_0 conda-forge jpeg 9d h8ffe710_0 conda-forge json5 0.9.5 pyh9f0ad1d_0 conda-forge jsonschema 3.2.0 py_2 conda-forge jupyter_client 6.1.11 pyhd8ed1ab_1 conda-forge jupyter_core 4.7.0 py39hcbf5309_0 conda-forge jupyter_server 1.2.2 py39hcbf5309_0 conda-forge jupyterlab 3.0.5 pyhd8ed1ab_0 conda-forge jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge jupyterlab_server 2.1.2 pyhd8ed1ab_0 conda-forge kealib 1.4.14 ha3510f1_0 conda-forge kiwisolver 1.3.1 py39h2e07f2f_1 conda-forge krb5 1.17.2 hbae68bd_0 conda-forge lazy-object-proxy 1.4.3 py39h4cdbadb_2 conda-forge libblas 3.9.0 7_mkl conda-forge libcblas 3.9.0 7_mkl conda-forge libcurl 7.71.1 h4b64cdc_8 conda-forge libffi 3.3 h0e60522_2 conda-forge libgdal 3.1.4 h0e5aa5a_0 conda-forge libglib 2.66.4 h5320221_1 conda-forge libiconv 1.16 he774522_0 conda-forge libkml 1.3.0 he9e54da_1012 conda-forge liblapack 3.9.0 7_mkl conda-forge libnetcdf 4.7.4 nompi_h3a9aa94_107 conda-forge libpng 1.6.37 h1d00b33_2 conda-forge libpq 12.3 h4f54205_3 conda-forge libsodium 1.0.18 h8d14728_1 conda-forge libspatialindex 1.9.3 he025d50_3 conda-forge libspatialite 5.0.0 hf693123_0 conda-forge libssh2 1.9.0 hb06d900_5 conda-forge libtiff 4.2.0 hc10be44_0 conda-forge libwebp-base 1.1.0 h8ffe710_3 conda-forge libxml2 2.9.10 hf5bbc77_3 conda-forge lz4-c 1.9.3 h8ffe710_0 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-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge markupsafe 1.1.1 py39hb82d6ee_3 conda-forge matplotlib-base 3.3.3 py39h581301d_0 conda-forge mccabe 0.6.1 py_1 conda-forge mistune 0.8.4 py39hb82d6ee_1003 conda-forge mkl 2020.4 hb70f87d_311 conda-forge msys2-conda-epoch 20160418 1 conda-forge munch 2.5.0 py_0 conda-forge nbclassic 0.2.6 pyhd8ed1ab_0 conda-forge nbclient 0.5.1 py_0 conda-forge nbconvert 6.0.7 py39hcbf5309_3 conda-forge nbformat 5.1.2 pyhd8ed1ab_1 conda-forge nest-asyncio 1.4.3 pyhd8ed1ab_0 conda-forge networkx 2.5 py_0 conda-forge notebook 6.2.0 py39hcbf5309_0 conda-forge numpy 1.19.5 py39h6635163_1 conda-forge olefile 0.46 pyh9f0ad1d_1 conda-forge openjpeg 2.3.1 h48faf41_3 conda-forge openssl 1.1.1i h8ffe710_0 conda-forge osmnx 1.0.1 pyhd3deb0d_0 conda-forge packaging 20.8 pyhd3deb0d_0 conda-forge pandas 1.2.0 py39h2e25243_1 conda-forge pandoc 2.11.3.2 h8ffe710_0 conda-forge pandocfilters 1.4.2 py_1 conda-forge parso 0.8.1 pyhd8ed1ab_0 conda-forge pcre 8.44 ha925a31_0 conda-forge pickleshare 0.7.5 py_1003 conda-forge pillow 8.1.0 py39hbc3ea3a_1 conda-forge pip 20.3.3 pyhd8ed1ab_0 conda-forge pixman 0.40.0 h8ffe710_0 conda-forge poppler 0.89.0 h810ce25_2 conda-forge poppler-data 0.4.10 0 conda-forge postgresql 12.3 h0f1a9bc_3 conda-forge proj 7.1.1 h7d85306_3 conda-forge prometheus_client 0.9.0 pyhd3deb0d_0 conda-forge prompt-toolkit 3.0.10 pyha770c72_0 conda-forge pycparser 2.20 pyh9f0ad1d_2 conda-forge pygments 2.7.4 pyhd8ed1ab_0 conda-forge pylint 2.6.0 py39hde42818_1 conda-forge pyopenssl 20.0.1 pyhd8ed1ab_0 conda-forge pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge pyproj 2.6.1.post1 py39hd2b018c_3 conda-forge pyrsistent 0.17.3 py39hb82d6ee_2 conda-forge pysocks 1.7.1 py39hcbf5309_3 conda-forge python 3.9.1 h7840368_3_cpython conda-forge python-dateutil 2.8.1 py_0 conda-forge python_abi 3.9 1_cp39 conda-forge pytz 2020.5 pyhd8ed1ab_0 conda-forge pywin32 300 py39hb82d6ee_0 conda-forge pywinpty 0.5.7 py39hde42818_1 conda-forge pyzmq 21.0.1 py39h6e08c89_0 conda-forge requests 2.25.1 pyhd3deb0d_0 conda-forge rtree 0.9.7 py39h09fdee3_1 conda-forge scikit-learn 0.24.0 py39he931e04_0 conda-forge scipy 1.6.0 py39hc0c34ad_0 conda-forge send2trash 1.5.0 py_0 conda-forge setuptools 49.6.0 py39hcbf5309_3 conda-forge shapely 1.7.1 py39hdfdf89f_1 conda-forge six 1.15.0 pyh9f0ad1d_0 conda-forge sniffio 1.2.0 py39hcbf5309_1 conda-forge sqlite 3.34.0 h8ffe710_0 conda-forge terminado 0.9.2 py39hcbf5309_0 conda-forge testpath 0.4.4 py_0 conda-forge threadpoolctl 2.1.0 pyh5ca1d4c_0 conda-forge tiledb 2.1.6 hf84e3da_1 conda-forge tk 8.6.10 h8ffe710_1 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge tornado 6.1 py39hb82d6ee_1 conda-forge traitlets 5.0.5 py_0 conda-forge tzdata 2020f he74cb21_0 conda-forge urllib3 1.26.2 pyhd8ed1ab_0 conda-forge vc 14.2 hb210afc_2 conda-forge vs2015_runtime 14.28.29325 h5e1d092_0 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge webencodings 0.5.1 py_1 conda-forge wheel 0.36.2 pyhd3deb0d_0 conda-forge win_inet_pton 1.1.0 py39hcbf5309_2 conda-forge wincertstore 0.2 py39hcbf5309_1006 conda-forge winpty 0.4.3 4 conda-forge wrapt 1.11.2 py39h4cdbadb_1 conda-forge xerces-c 3.2.3 h0e60522_2 conda-forge xz 5.2.5 h62dcd97_1 conda-forge zeromq 4.3.3 h0e60522_3 conda-forge zipp 3.4.0 py_0 conda-forge zlib 1.2.11 h62dcd97_1010 conda-forge zstd 1.4.8 h4e2f164_1 conda-forge


Details about conda and system ( conda info ):

$ conda info
   active environment : ox
    active env location : D:\ProgramFilesTS\Anaconda3\envs\ox
            shell level : 2
       user config file : C:\Users\zxcy\.condarc
 populated config files : C:\Users\zxcy\.condarc
          conda version : 4.9.2
    conda-build version : 3.20.5
         python version : 3.8.5.final.0
       virtual packages : __cuda=10.2=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : D:\ProgramFilesTS\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : D:\ProgramFilesTS\Anaconda3\pkgs
                          C:\Users\zxcy\.conda\pkgs
                          C:\Users\zxcy\AppData\Local\conda\conda\pkgs
       envs directories : D:\ProgramFilesTS\Anaconda3\envs
                          C:\Users\zxcy\.conda\envs
                          C:\Users\zxcy\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.9.2 requests/2.24.0 CPython/3.8.5 Windows/10 Windows/10.0.18362
          administrator : False
             netrc file : None
           offline mode : False

gboeing commented 3 years ago

Did you try the troubleshooting tips at the link provided in your traceback? https://numpy.org/devdocs/user/troubleshooting-importerror.html It includes VSCode notes.

Is your problem limited to VSCode? Can you import OSMnx with a standard python interpreter from your command prompt:

conda activate ox
python -c "import osmnx; print(osmnx.__version__)"
zyforcode commented 3 years ago

m

Yes, I tried that tips and I chose the right python interpreter. I have installed multiple versions of Python, here are my python versions: image I can import import OSMnx with a standard python interpreter from my command prompt, like this: image I think this problem is only limited to VSCode, I can import OSMnx with PyCharm Community Edition 2020.2, and I can import OSMnx with the jupyter notebook extension of VSCode. So I'm not sure what the real problem is. image

gboeing commented 3 years ago

If you're able to import OSMnx in the python interpreter, PyCharm, and the Jupyter notebook extension for VSCode, it sounds like OSMnx is installed properly on your system. Sounds like a VSCode configuration issue. I don't use VSCode so I'm afraid I don't have any further advice.

zyforcode commented 3 years ago

Ok. Thanks a lot。