conda-forge / osmnx-feedstock

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

Import error with OSMNX remains #83

Closed PimCornelis closed 3 years ago

PimCornelis commented 3 years ago

Issue:

Installed OSMNX through this line of code in anaconda 3: image

I got an import error: ImportError: cannot import name 'CRS' from 'pyproj' (C:\Users\Pim_C\anaconda3\lib\site-packages\pyproj__init__.py)

I tried following the official OSMNX installation instructions posted on stack overflow by the OSMNX developer. The error remained.

Tried uninstalling OSMNX through 'conda uninstall osmnx'

Tried re-installing OSMNX through official documentation mentioned above. Error still remains


Environment (conda list):

``` $ conda list ```


Details about conda and system ( conda info ):

``` $ conda info ```
gboeing commented 3 years ago

Where did you see that on StackOverflow? It must be years old, given that it's long since obsolete and will not result in a working installation. Please read the OSMnx documentation and follow the documented official installation instructions: https://osmnx.readthedocs.io/en/stable/

PimCornelis commented 3 years ago

https://stackoverflow.com/questions/59658167/cannot-import-name-crs-from-pyproj-for-using-the-osmnx-library

Actually replied by you some 5 months ago @gboeing. That's also how I ended up here. The initial installation command I posted a screencap of; "conda install -c conda-forge osmnx" came from a quick google search when I first wanted to get started with osmnx (just learned about its existence last week). But I think that somehow messed with my installation. As mentioned above I tried removing and reinstalling through the link you posted, but the error posted in the original question remains.

gboeing commented 3 years ago

It looks like your import is pulling pyproj from your default site-packages rather than your conda environment you created in the installation. Did you run conda activate ox?

gboeing commented 3 years ago

Also, @PimCornelis when you said

Actually replied by you some 5 months ago @gboeing

in response to me saying

Where did you see that on StackOverflow? It must be years old, given that it's long since obsolete and will not result in a working installation.

Note that I was referring to the installation command you said you used and supplied a screenshot of (conda install -c conda-forge osmnx). That will usually result in a broken OSMnx installation, like you're seeing.

However, the installation instructions in the StackOverflow link you provided are correct and match the documented installation instructions. If you follow these documented instructions, your installation will work. If you've installed it in a dedicated conda environment, as per the instructions, you can run OSMnx from your terminal with:

conda activate ox
python
>>> import osmnx as ox
>>> print (ox.__version__)
PimCornelis commented 3 years ago

@gboeing I think we're getting somewhere: image

I am all doing this from my anaconda prompt, but when I open spyder and try to import osmnx as "import osmnx as ox" I still get that import error.

edit: I will add a screenshot of my python console: image

PimCornelis commented 3 years ago

Apparently, I was unaware that I had to launch Spyder from the ox environment. I have now installed osmnx through the official installation instructions and in the ox environment I installed Spyder. I did this in Anaconda Navigator. However, Spyder is able to launch only once, stays open for a couple of seconds before crashing again. From this point trying to launch Spyder in the ox environment doesn't work anymore.

Are there any versions you are aware of that are currently incompatible with OSMnx? Or should Anaconda Navigator 2.1.0 and Spyder 4.2.5 be fine?

gboeing commented 3 years ago

@PimCornelis this isn't a compatibility issue with OSMnx itself, which is pure Python. You'd have to direct your question to the Spyder community: I do not use Spyder and thus cannot advise you on it. However, these resources may be relevant. Your test above demonstrates that OSMnx is properly installed and working. The question is how to use Spyder with a specific conda environment, and that should be directed to the relevant community, perhaps on StackOverflow.