18

I'm trying to solve my issue in my own but I couldn't, I'm trying to run this code in every format you can imagine and in ArcGIS pro software it's the same I can't find this error message in any other issue. From similar issues, it seems some data files could be missing?

import geopandas as gpd
import json
import numpy as np
from shapely.geometry import LineString, Point, box
import ast
from pyproj import Proj
paths = road_features.SHAPE.map(lambda x: np.array(ast.literal_eval(x)["paths"][0]))
pathLineStrings = paths.map(LineString)
gdf = gpd.GeoDataFrame(road_features,geometry=pathLineStrings)
#gdf.crs = {'init': 'epsg:3857'}
gdf.crs = {'init': 'epsg:4326'}
gdf = gdf.to_crs({'init': 'epsg:4326'})

i get this error

RuntimeError: b'no arguments in initialization list'

also i tried it in arcgis pro i got the same

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\geopandas\geodataframe.py", line 443, in to_crs
    geom = df.geometry.to_crs(crs=crs, epsg=epsg)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\geopandas\geoseries.py", line 304, in to_crs
    proj_in = pyproj.Proj(self.crs, preserve_units=True)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pyproj\__init__.py", line 362, in __new__
    return _proj.Proj.__new__(self, projstring)
  File "_proj.pyx", line 129, in _proj.Proj.__cinit__
RuntimeError: b'no arguments in initialization list'
3
  • 1
    I ran into an error on an Anaconda, Windows 10 installation in which the pyproj package's file datadir.py was pointing to the wrong location for the proj file epsg. (.../Anaconda3\share\proj instead of ...\Anaconda3\Library\share). Editing datadir.py fixed the issue for me. Commented Aug 16, 2019 at 0:21
  • 1
    Interestingly, if I launch either JupyterLab or Jupyter Notebook from Anaconda Navigator or Anaconda Prompt, rather than from an Anaconda Powershell Prompt, I get no errors! Shouldn't these all be the same? Why is Anaconda Powershell Prompt messing up?
    – Chad
    Commented Aug 29, 2019 at 18:54
  • I have exactly this same problem. Works fine when starting jupyter from Miniconda prompt but not when starting from Miniconda Powershell prompt. Thanks for the tip, any idea what's going on? Commented Oct 1, 2019 at 10:56

8 Answers 8

26

to make sure this is pyproj error rather than geopandas.

import pyproj
pyproj.Proj("+init=epsg:4326")

if the above runtime error is the same, we can be sure this error is due to pyproj.

just conda remove pyproj and install it with pip.

pip install pyproj

at least this works for me.

Today(July 30), I resintalled from miniconda, conda remove pyproj did not work for me, instead I pip uninstall pyproj and pip install pyproj makes everything fine.

3
  • 2
    Thank you! Removing by conda, then pip install pyproj. It works for me. Commented Jun 20, 2019 at 12:16
  • 2
    In uninstalling pyproj, it may be easier to run pip remove pyproj --force to avoid uninstalling geopandas or other dependencies Commented Sep 26, 2019 at 20:37
  • 3
    Ran into the same problem, and I used pip install --force-reinstall pyproj to avoid conda remove pyproj which removes packages that depend on pyproj like geopandas
    – Allen
    Commented Jul 13, 2020 at 5:50
15

The problem is problably within the pyproj instalation of Anaconda on Windows platform. Just like Stephen said, solution is to edit the path in "datadir.py" (located in ...Anaconda3\Lib\site-packages\pyproj).

Correct path is ".../Anaconda3/Library/share". Make sure full path is complete (may contain username etc.). I also needed to change \ to /. This change worked for me. Yes and after this change, it is necesary to restart Spyder (or whatever you use).

7

Is there an initial crs defined? I ran into the same problem only when I passed only the epsg command: gdf.to_crs('epsg:4326').

As you show

my_geoseries.crs = {'init' :'epsg:3857'}

should be the first step and then transforming to

gdf = gdf.to_crs({'init': 'epsg:4326'})

If you are working in ArcGIS you could also check in the properties whether the initial epsg is defined ?

7

I'm using Pycharm. I had to use a combination of both Stone Shi's remark and Dorregaray's.

import pyproj
pyproj.Proj("+init=epsg:4326")
> RuntimeError: b'no arguments in initialization list'

According to Stone Shi, the above proves that it's a pyproj err. So I used Pycharm->Settings and reinstalled pyproj. Then

import pyproj
pyproj.Proj("+init=epsg:4326")
> RuntimeError: b'no arguments in initialization list'

So, it's a pyproj err but Pycharm->Settings reinstalling pyproj does not help me.

I then edited my C:\Anaconda3\Lib\site-packages\pyproj\datadir.py from:

pyproj_datadir="C:/Anaconda3\share\proj"

to Dorregaray's:

pyproj_datadir="C:\Anaconda3\Library\share"

Then test again:

import pyproj
pyproj.Proj("+init=epsg:4326")
>Process finished with exit code 0

No Runtime Error!

Then test on my

wgs84  = data.to_crs({'init': 'epsg:4269'})
>Process finished with exit code 0
3

For me upgrading pyproj and geopandas, fixed this issue:

pip install pyproj --upgrade 
pip install geopandas --upgrade 
1

Using Geopandas, try that (it should work) :

gdf = gpd.GeoDataFrame(gdf, geometry=gdf['geometry'])
gdf.crs = {'init' :'epsg:2154'}
gdf = gdf.to_crs({'init' :'epsg:4326'}) 

You should redefine well your geodataframe, then define the initial geo referential and finally convert it in the good one. Don't forget to drop the NaN if there are any.

1

you can force reinstall pyproj from pip directly using

pip install --upgrade --force-reinstall pyproj

instead of uninstalling and reinstall again which will also uninstall all the dependent libraries

0

I came across the same error. I was working with Python version 3.6.3 and Geopandas version 0.4.0. It was solved by using the following instead of df = df.to_crs({'init': 'epsg:4326'}):

df = df.to_crs(epsg=4326)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.