简体   繁体   中英

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

I have used a fresh anaconda install to download and install all the required modules for osnmx library but I got the following error: 在此处输入图片说明

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.

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM