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 after installation #42

Closed jellyfishrui closed 5 years ago

jellyfishrui commented 5 years ago

Issue: Cannot import osmnx after conda installation

Here's the error codes:


OSError Traceback (most recent call last)

in ----> 1 import osmnx ~\Miniconda3\lib\site-packages\osmnx\__init__.py in 7 ################################################################################ 8 ----> 9 from .buildings import * 10 from .core import * 11 from .elevation import * ~\Miniconda3\lib\site-packages\osmnx\buildings.py in 6 ################################################################################ 7 ----> 8 import geopandas as gpd 9 import matplotlib.pyplot as plt 10 import time ~\Miniconda3\lib\site-packages\geopandas\__init__.py in ----> 1 from geopandas.geoseries import GeoSeries 2 from geopandas.geodataframe import GeoDataFrame 3 4 from geopandas.io.file import read_file 5 from geopandas.io.sql import read_postgis ~\Miniconda3\lib\site-packages\geopandas\geoseries.py in 2 import json 3 ----> 4 import numpy as np 5 from pandas import Series 6 import pyproj ~\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py in 140 from . import _distributor_init 141 --> 142 from . import core 143 from .core import * 144 from . import compat ~\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py in 21 # NOTE: would it change behavior to load ALL 22 # DLLs at this path vs. the name restriction? ---> 23 WinDLL(os.path.abspath(filename)) 24 DLL_filenames.append(filename) 25 if len(DLL_filenames) > 1: ~\Miniconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error) 354 355 if handle is None: --> 356 self._handle = _dlopen(self._name, mode) 357 else: 358 self._handle = handle OSError: [WinError 193] %1 is not a valid Win32 application
Environment (conda list):
(base) C:\Users\jelly>conda list ``` $ conda list ``` # packages in environment at C:\Users\jelly\Miniconda3: # # Name Version Build Channel altair 2.4.1 py37_0 conda-forge asn1crypto 0.24.0 py37_0 attrs 19.1.0 py_0 conda-forge backcall 0.1.0 py_0 conda-forge blas 1.0 mkl bleach 3.1.0 py_0 conda-forge boost-cpp 1.68.0 h6a4c333_1000 conda-forge branca 0.3.1 py_0 conda-forge bzip2 1.0.6 hfa6e2cd_1002 conda-forge ca-certificates 2019.3.9 hecc5488_0 conda-forge certifi 2019.3.9 py37_0 conda-forge cffi 1.11.5 py37h74b6da3_1 chardet 3.0.4 py37_1 click 7.0 py_0 conda-forge click-plugins 1.0.4 py_0 conda-forge cligj 0.5.0 py_0 conda-forge colorama 0.4.1 py_0 conda-forge conda 4.6.8 py37_0 conda-forge conda-env 2.6.0 1 console_shortcut 0.1.1 3 cryptography 2.4.2 py37h7a1dbc1_0 curl 7.64.0 h4496350_2 conda-forge cycler 0.10.0 py_1 conda-forge decorator 4.3.2 py_0 conda-forge defusedxml 0.5.0 py_1 conda-forge descartes 1.1.0 py_2 conda-forge entrypoints 0.3 py37_1000 conda-forge expat 2.2.5 he025d50_1002 conda-forge fiona 1.8.4 py37h0d92105_1001 conda-forge folium 0.8.0 py_0 conda-forge freetype 2.9.1 h5db478b_1005 conda-forge freexl 1.0.5 hd288d7e_1002 conda-forge gdal 2.3.3 py37hdf43c64_0 geographiclib 1.49 py_0 conda-forge geopandas 0.4.1 py_0 conda-forge geopy 1.18.1 py_0 conda-forge geos 3.7.1 he025d50_1000 conda-forge hdf4 4.2.13 hf8e6fe8_1002 conda-forge hdf5 1.10.4 nompi_hcc15c50_1105 conda-forge icc_rt 2019.0.0 h0cc432a_1 icu 58.2 ha66f8fd_1 idna 2.8 py37_0 intel-openmp 2019.1 144 ipykernel 5.1.0 py37h39e3cac_1002 conda-forge ipython 7.3.0 py37h39e3cac_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge jedi 0.13.3 py37_0 conda-forge jinja2 2.10 py_1 conda-forge jpeg 9c hfa6e2cd_1001 conda-forge jsonschema 3.0.1 py37_0 conda-forge jupyter_client 5.2.4 py_3 conda-forge jupyter_core 4.4.0 py_0 conda-forge kealib 1.4.10 heacb130_1002 conda-forge kiwisolver 1.0.1 py37he980bc4_1002 conda-forge krb5 1.16.3 hdd46e55_1001 conda-forge libcurl 7.64.0 h4496350_2 conda-forge libgdal 2.3.3 h10f50ba_0 libiconv 1.15 hfa6e2cd_1004 conda-forge libkml 1.3.0 h4fd0f3b_1009 conda-forge libnetcdf 4.6.2 h396784b_1001 conda-forge libpng 1.6.36 h7602738_1000 conda-forge libpq 11.2 hb0bdaea_0 conda-forge libsodium 1.0.16 h2fa13f4_1001 conda-forge libspatialindex 1.8.5 he025d50_1003 conda-forge libspatialite 4.3.0a h6a0152f_1026 conda-forge libssh2 1.8.0 h642c060_1004 conda-forge libtiff 4.0.10 h36446d0_1001 conda-forge libxml2 2.9.8 h9ce36c8_1005 conda-forge m2w64-gcc-libgfortran 5.3.0 6 m2w64-gcc-libs 5.3.0 7 m2w64-gcc-libs-core 5.3.0 7 m2w64-gmp 6.1.0 2 m2w64-libwinpthread-git 5.0.0.4634.697f757 2 mapclassify 2.0.1 py_0 conda-forge markupsafe 1.1.1 py37hfa6e2cd_0 conda-forge matplotlib 3.0.3 py37_0 conda-forge matplotlib-base 3.0.3 py37h3e3dc42_0 conda-forge menuinst 1.4.14 py37hfa6e2cd_0 mistune 0.8.4 py37hfa6e2cd_1000 conda-forge mkl 2019.1 144 mkl_fft 1.0.10 py37hfa6e2cd_1 conda-forge mkl_random 1.0.2 py37h830ac7b_2 conda-forge msys2-conda-epoch 20160418 1 munch 2.3.2 py_0 conda-forge nbconvert 5.4.1 py_2 conda-forge nbformat 4.4.0 py_1 conda-forge networkx 2.2 py_1 conda-forge notebook 5.7.5 py37_0 conda-forge numpy 1.16.2 py37h19fb1c0_0 numpy-base 1.16.2 py37hc3f5095_0 openssl 1.1.1b hfa6e2cd_1 conda-forge osmnx 0.9 py_1 conda-forge pandas 0.24.1 py37h6538335_0 conda-forge pandoc 2.6 1 conda-forge pandocfilters 1.4.2 py_1 conda-forge parso 0.3.4 py_0 conda-forge pcre 8.42 hd6b2f15_0 pickleshare 0.7.5 py37_1000 conda-forge pip 18.1 py37_0 proj4 5.2.0 hfa6e2cd_1001 conda-forge prometheus_client 0.6.0 py_0 conda-forge prompt_toolkit 2.0.9 py_0 conda-forge pycosat 0.6.3 py37hfa6e2cd_0 pycparser 2.19 py37_0 pygments 2.3.1 py_0 conda-forge pyopenssl 18.0.0 py37_0 pyparsing 2.3.1 py_0 conda-forge pyproj 1.9.6 py37h1fcc0e4_1000 conda-forge pyqt 5.9.2 py37h6538335_2 pyrsistent 0.14.11 py37hfa6e2cd_0 conda-forge pysocks 1.6.8 py37_0 python 3.7.1 h8c8aaf0_6 python-dateutil 2.8.0 py_0 conda-forge pytz 2018.9 py_0 conda-forge pywin32 223 py37hfa6e2cd_1 pywinpty 0.5.5 py37_1000 conda-forge pyzmq 18.0.1 py37he418aac_0 conda-forge qt 5.9.7 vc14h73c81de_0 requests 2.21.0 py37_0 rtree 0.8.3 py37_1000 conda-forge ruamel_yaml 0.15.46 py37hfa6e2cd_0 scipy 1.2.1 py37h29ff71c_0 send2trash 1.5.0 py_0 conda-forge setuptools 40.6.3 py37_0 shapely 1.6.4 py37h8921fb9_1002 conda-forge sip 4.19.8 py37h6538335_1000 conda-forge six 1.12.0 py37_0 sqlite 3.26.0 he774522_0 terminado 0.8.1 py37_1001 conda-forge testpath 0.4.2 py37_1000 conda-forge tk 8.6.9 hfa6e2cd_1000 conda-forge toolz 0.9.0 py_1 conda-forge tornado 6.0.1 py37hfa6e2cd_0 conda-forge traitlets 4.3.2 py37_1000 conda-forge urllib3 1.24.1 py37_0 vc 14.1 h0510ff6_4 vincent 0.4.4 py_1 conda-forge vs2015_runtime 14.15.26706 h3a45250_0 wcwidth 0.1.7 py_1 conda-forge webencodings 0.5.1 py_1 conda-forge wheel 0.32.3 py37_0 win_inet_pton 1.0.1 py37_1 wincertstore 0.2 py37_0 winpty 0.4.3 4 conda-forge xerces-c 3.2.2 h6538335_1001 conda-forge xz 5.2.4 h2fa13f4_1001 conda-forge yaml 0.1.7 hc54c509_2 zeromq 4.2.5 he025d50_1006 conda-forge zlib 1.2.11 h2fa13f4_1004 conda-forge

Details about conda and system ( conda info ):
`` $ conda info ``` active environment : base active env location : C:\Users\jelly\Miniconda3 shell level : 1 user config file : C:\Users\jelly\.condarc populated config files : C:\Users\jelly\.condarc conda version : 4.6.8 conda-build version : not installed python version : 3.7.1.final.0 base environment : C:\Users\jelly\Miniconda3 (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/free/win-64 https://repo.anaconda.com/pkgs/free/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 : C:\Users\jelly\Miniconda3\pkgs C:\Users\jelly\.conda\pkgs C:\Users\jelly\AppData\Local\conda\conda\pkgs envs directories : C:\Users\jelly\Miniconda3\envs C:\Users\jelly\.conda\envs C:\Users\jelly\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/4.6.8 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17134 administrator : False netrc file : None offline mode : False
gboeing commented 5 years ago

@jellyfishrui can you tell me more about how you installed it? Did you create a virtual env? Can you provide the specific commands you used?

jellyfishrui commented 5 years ago

@gboeing Hi Professor Boeing, I checked this blog on your website and used the command there: https://geoffboeing.com/2017/02/python-getting-started/

I uninstalled and reinstalled all the python versions, conda and pycharm but it remained the same.

I also tried creating a virtual env in pycharm but the [WinError 193] still popped up no matter where I was trying to import osmnx: Jupyter Notebook, spyder or pycharm.

gboeing commented 5 years ago

I'd recommend creating a new clean conda environment:

conda config --prepend channels conda-forge
conda create -n ox --yes python=3 osmnx jupyterlab
conda activate ox
python -c "import osmnx; print(osmnx.__version__)"

See if that runs successfully and prints out the osmnx version.

jellyfishrui commented 5 years ago

@gboeing Hi Professor Boeing, I uninstalled conda and all versions of python, and run the commands exactly following your advice. But the [WinError193] pops up again. I googled and got the answer that this is a reconciliation issue between 32 and 64.

What is weird is that I installed miniconda for win64 but the python inside is win32. Here's what I get I tried to check the python version installed from conda.

Python 3.7.1 | packaged by conda-forge | (default, Mar 13 2019, 13:32:59) [MSC v.1900 64 bit (AMD64)] :: Anaconda, Inc. on win32

But I'm using 64-bit system so I'm confused.

gboeing commented 5 years ago

In that case this doesn't sound like an OSMnx issue and I'm not sure if I can help. It appears that you've installed the 32 bit version of python onto your 64 bit system (which is possible). You should install the 64 bit version.

jellyfishrui commented 5 years ago

@gboeing I uninstalled miniconda64 and tried installing conda32. It eventually worked! I cannot be grateful to all your patience! Honestly speaking, my computer science knowledge doesn't enable to fully understand the logic behind that though I roughly know it's the system reconciliation issue. Now cannot wait to explore this powerful tool! Thank you very much again!

gboeing commented 5 years ago

@jellyfishrui happy to hear you got it working! Good luck.

ocefpaf commented 5 years ago

What is weird is that I installed miniconda for win64 but the python inside is win32.

Not that sys.platform on Windows always return win32, even on modern 64 Windows! I know, confusing. I also do not recommend you using a miniconda for Windows 32 in a 64 machine. (And conda-forge no longer builds 32.)

My recommendation for Windows users are:

That is usually the most stable option at the moment for Windows users.

jellyfishrui commented 5 years ago

@ocefpaf Thank you very much for your reply. I tried your solution and went with miniconda 64. What's tricky that the [WinError193] pops up again. I'm 100% sure I'm using a 64-bit system.

(ox) C:\Users\jelly>python -c "import osmnx; print(osmnx.version)" Traceback (most recent call last): File "", line 1, in File "C:\Users\jelly\Miniconda3\envs\ox\lib\site-packages\osmnx__init.py", line 9, in from .buildings import * File "C:\Users\jelly\Miniconda3\envs\ox\lib\site-packages\osmnx\buildings.py", line 8, in import geopandas as gpd File "C:\Users\jelly\Miniconda3\envs\ox\lib\site-packages\geopandas\init.py", line 1, in from geopandas.geoseries import GeoSeries File "C:\Users\jelly\Miniconda3\envs\ox\lib\site-packages\geopandas\geoseries.py", line 4, in import numpy as np File "C:\Users\jelly\AppData\Roaming\Python\Python37\site-packages\numpy\init.py", line 142, in from . import core File "C:\Users\jelly\AppData\Roaming\Python\Python37\site-packages\numpy\core\init.py", line 23, in WinDLL(os.path.abspath(filename)) File "C:\Users\jelly\Miniconda3\envs\ox\lib\ctypes\init.py", line 356, in init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application

And even if I go with miniconda 32, each time I restart the computer, nothing works any more. I just the only way is probably to switch to mac or linux.

ocefpaf commented 5 years ago

I'm 100% sure I'm using a 64-bit system.

OK. In that case stick with miniconda 32, it does look like your system is not a win64.

jellyfishrui commented 5 years ago

@ocefpaf Thank you for your time. It ended up with the situation that whenever the computer restarts, nothing works no matter with 32 or 64. I think there must be something wrong when the win10 system was installed on my computer so I switched to my old laptop and it eventually worked there.

jellyfishrui commented 5 years ago

I just found a way to solve this problem without installing it on windows. Since I couldn't use Docker either on my laptop because I'm using windows family version, I eventually found Azure Notebook. Rtree must be installed first and then install osmnx via conda or pip. !conda install osmnx -y
or !pip install osmnx Eventually it worked without installing anything on my laptop! Anyone with internet can use this method.

rampallishyam commented 5 years ago

python -c "import osmnx; print(osmnx.version)"

I really works.

I have installed a clean anaonda 64-bit on my 64-bit system. Then I have executed those four lines of code and opened Jupyter notebook and it works. Great. Just need a little patience.

From what Prof. Boeing says, It is not suggested to use pip since it gave me a heavy headache.

MilkwoodSF commented 4 years ago

Wow! Not sure how I got here. Not sure what just happened. Always fearful pulling strings on my newbie python sweater... AND it worked like a charm. Much gratitude and can't wait to learn and contribute (someday) to this exciting package! Many thanks for your efforts!