pyproj: "no arguments in initialization list" runtime error
Hi, I’m running into a cryptic error. My CRS in the geopandas dataframe seems to be properly set, however I cannot convert it to any other CRS.
>>> print(gdf_PLU.crs)
epsg:2193
>>>gdf_PLU.to_crs(epsg=4326)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-92-46b32e6c8012> in <module>()
1 print(gdf_PLU.crs)
----> 2 gdf_PLU.to_crs(epsg=4326)
~/anaconda3/envs/hthf/lib/python3.6/site-packages/geopandas/geodataframe.py in to_crs(self, crs, epsg, inplace)
384 else:
385 df = self.copy()
--> 386 geom = df.geometry.to_crs(crs=crs, epsg=epsg)
387 df.geometry = geom
388 df.crs = geom.crs
~/anaconda3/envs/hthf/lib/python3.6/site-packages/geopandas/geoseries.py in to_crs(self, crs, epsg)
283 except TypeError:
284 raise TypeError('Must set either crs or epsg for output.')
--> 285 proj_in = pyproj.Proj(self.crs, preserve_units=True)
286 proj_out = pyproj.Proj(crs, preserve_units=True)
287 project = partial(pyproj.transform, proj_in, proj_out)
~/anaconda3/envs/hthf/lib/python3.6/site-packages/pyproj/__init__.py in __new__(self, projparams, preserve_units, **kwargs)
356 # on case-insensitive filesystems).
357 projstring = projstring.replace('EPSG','epsg')
--> 358 return _proj.Proj.__new__(self, projstring)
359
360 def __call__(self, *args, **kw):
_proj.pyx in _proj.Proj.__cinit__ (_proj.c:1170)()
RuntimeError: b'no arguments in initialization list'
I can’t find this error message in any other issue. From similar issues it seems some data files could be missing (if so, how can I install them; I’m using the binary that is dragged in by conda-forge geopandas). Or is it something else?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 69 (13 by maintainers)
so I had the same problem. Using conda uninstall pyproj and then pip install pyproj worked to run the code
With pip version 2.2.1 is installed, so that workes, but conda uses Version 1.9.6.
But once I installed geopandas, conda would install pyproj with Version 1.9.6 again and then my code would also crashed again.
It worked, once I manually deleted the pyproj folder in anaconda\Lib\site-packages instead of using conda uninstall. And then use pip install pyproj.
Thanks a lot for all the helpful comments ! The solution of @rickantonais worked for me too:
After a bit of frigging around I was able to figure out the problem. I downloaded the repo source code and copied the folder
pyproj-master.zip\pyproj-master\lib\pyproj\dataand copied to the location indicated insite-packages/pyproj/data/epsgdatadir.py(making sure the names lined up, I had to rename the folder fromdatatoprojAfter that, the library worked perfectly. Perhaps it is a problem with using Anaconda to install it, but this extremely crucial data folder was simply not copied, or was possibly copied to the wrong location.
I’m encountering this error still and nothing in this thread has helped. I have tried:
Every single one of them returns
RuntimeError: b'no arguments in initialization list'Python version is 3.6 and pyproj version is 1.9.5.1, installed with anaconda
Hi, guys. I meet the problem on Win7 and anaconda. My code run well on ubuntu, but get the above problem. I have a simple solution, just uninstall the pyproj from anaconda and use pip install instead. It works on my win7.
hey guys !
thank you so much for the help and suggestions. i had the same exact problem as @rgommers after following @Eskapp and @iboates steps everything seem to work fine. I will briefly explain what i did for those who are still facing problems.
I encountered this error when I tried to run:
On the following setup:
I fixed the error by editing the file
datadir.pychanged.../Anaconda3\share\projto...\Anaconda3\Library\shareJust had the same trouble after re-installing all my packages and the solution of @jfnk worked perfect for me but I didn’t need to download any folder, just put the following code in order to make it work :
os.environ['PROJ_LIB']=r"C:\Users\[...replace accordingly...]\Anaconda3\Library\share"Same observation. Issue is gone with upgrading to 2.1.* version.
I experienced the same Error (using an anaconda python 3.6 and pyproj 1.9.5.1) and fixed it by manually downloading the data directory as suggested by @Eskapp and then set the
PROJ_LIBenvironment variable to point to the data directory.This fixed the issue.
Maybe this is due to an error in the conda recipe?
OK, I actually figured out the issue we were having. We activate the environment and then install everything other than Python in it. But latest proj builds set
PROJ_LIBand we need to activate the environment after installing it. Easiest fix was to request all needed packages when creating the environment, and then activate it.So for anyone else hitting this, make sure you a) are installing in an environment, not the root, and; b) activate after installing proj (or pyproj).
@zuzhaoye 's solution:
Worked for me, albeit it throws up a warning message, documenting it here:
@smcateer’s answer (https://github.com/pyproj4/pyproj/issues/134#issuecomment-521846924) worked for me as well… and for all those who somehow missed where to look for the file
datadir.py(like I did), it’s located here in the folder\Lib\site-packages\pyprojof the environment in question.This will definitely churn some stomachs. Case1: Open the jupyter notebook with correponding environment (geo_env) directly and call the method to_crs — Error “RuntimeError: b’no arguments in initialization list’”
Case2: I open anaconda prompt, activate my environment (geo_env), start my jupyter notebook and call the method to_crs — No Errors!!!
@snowman2
gives:
This solution worked for me as well. Installed pyproj with conda. Windows 7.
Just fyi, this issue has gone away for me with the 2.1.* versions.
Can y’all try pyproj==2.1.0 and see if it resolved this issue. You can install it with:
pip install pyproj==2.1.0to use binary wheels or with:conda install -c conda-forge pyproj=2.1.0I do notice however that @rgommers’ folder where he found all the projection definitions (site-packages/pyproj/data/epsg) does not seem to exist for me, instead all I found was a python file called
datadir.pywith a link to the filepathC:/FILES/boates/Anaconda/envs/cavi-3dscene-generator\share\proj, which does not seem to even exist, nosharefolder in is inC:/FILES/boates/Anaconda/envs/cavi-3dscene-generatorI’ll need to dig it out of a larger code base and change to dummy data, but will try that in a few hours.