Cannot import name 'CRS' from 'pyproj' for using the osmnx library
Asked Answered
C

4

5

I have used a fresh anaconda install to download and install all the required modules for osnmx library but I got the following error: enter image description here

Cheeky answered 9/1, 2020 at 6:14 Comment(3)
Please don’t share information as an image unless absolutely necessary.Sheasheaf
What version of pyproj do you have installed? You need 2+.Oriana
See some hints here, github.com/gboeing/osmnx/issues/400 I thought it is over now, with conda and stuff, you do not need to collect wheels, eggs, over various servers, and you have it all in powershell as easy as on Mac/Unix. NO. After 2 yeras with mac i needed to install on windows server.... 2 days of various bugs, including adding to PATH, installing C++ from Visual Studio, compiling C and stuff... dude, I hoped those times were gone.Stalk
B
11

I am the developer of OSMnx. There is a growing amount of misinformation and confusion in this thread, so I will give you a definitive answer.

Just follow the documented installation instructions to install the latest release of OSMnx:

conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx

If you install an old version of pyproj + a new version of OSMnx, or an old version of OSMnx + a new version of pyproj, you will get package conflicts such as the ImportError above. The same problems can crop up if you just conda install it or pip install it without following the documented installation instructions. Required dependency versions can be seen here. Make sure you have 64-bit python (anaconda/miniconda) installed. OSMnx is pure Python and thus its installation alone is trivial, but, it depends on geopandas which itself has tricky dependencies to install. If you follow the documented installation instructions, it should all be smooth and seamless.

To summarize:

  • do just follow the simple installation instructions in the OSMnx documentation
  • don't just run conda install osmnx
  • don't just run pip install osmnx
  • don't run pip install -U pyproj psutil
  • don't use pip at all unless you have already installed all of OSMnx's dependencies and confirmed they are all working properly (note: this is nontrivial)

If you follow the installation instructions in the documentation and still have trouble, please report what you did step by step with full details at the feedstock so we can reproduce it and quickly fix it!

Again, the installation instructions are in the documentation.

Beirut answered 17/7, 2020 at 16:22 Comment(3)
Unfortunately it seems using environments on Windows no longer works: github.com/conda/conda/issues/10025Lace
Using conda environments on windows continues to work just fine. If you're experiencing an installation problem with it, please open an issue at the OSMnx conda-forge repo, so we can reproduce and troubleshoot it.Beirut
Today the environment I created works. It is possible that you need to restart your PC after installing?Lace
P
6

I have had the same issue and turned out that it did not like the latest release of osmnx (0.11.3). It could be that that version is unstable as its new (9th January 2020).

I have sort out the issue by uninstalling the osmnx 0.11.3

conda uninstall osmnx

and forcing to install the osmnx 0.11 version

pip install osmnx==0.11
Partin answered 11/1, 2020 at 18:39 Comment(2)
Did not work for me, pip cannot install osmnx , keeps on hiting some bugs, thw only way to install osmnx on widnows seem to be from conda, yet now there is this error. I spent 2nd day installing osmnx on windows..... cool!Stalk
This is not the correct answer. I am the package developer. I have provided a detailed answer below, including where to go if you follow the documented installation instructions and still get an error. The installation should be simple and straightforward if you follow my instructions.Beirut
B
0

For what it's worth, I had trouble with installing this too (and am completely new to Python). The most recent MacOSX download of anaconda (2020.11) contained version 2.3 (I think it was) of networkx and I saw that this does not satisfy the required dependency listed. Anyway, having installed the networkx to 2.5 it now works swimmingly. Thanks for the package!

Brahmin answered 16/4, 2021 at 15:4 Comment(1)
Is this an answer or a "Thank you"?Lorou
S
0

I tried all solutions, but nothing worked with me. Then, I tried this line below and everything worked:

pip install -U pyproj psutil
Salot answered 20/10, 2022 at 7:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.