我在使用IPython Notebook时执行pyproj
时遇到问题,但在powershell中使用Python时却没有。
IPython引发了以下错误:
RuntimeError Traceback (most recent call last)
<ipython-input-59-384a2e8bfd70> in <module>()
----> 1 inproj = pyproj.Proj(init='epsg:3857')
C:\Anaconda64\lib\site-packages\pyproj\__init__.pyc in __new__(self, projparams, preserve_units, **kwargs)
345 else:
346 kvpairs.append(kvpair+' ')
--> 347 projstring = ''.join(kvpairs)
348 # look for EPSG, replace with epsg (EPSG only works
349 # on case-insensitive filesystems).
_proj.pyx in _proj.Proj.__cinit__ (_proj.c:1190)()
RuntimeError: Invalid argument
问题类似于此处https://github.com/jswhit/pyproj/issues/17所指出的问题,但我不了解代码如何在命令行上运行良好。你知道如何让pyproj
工作吗?我使用的是Windows(64位),conda版本:3.18.6和python版本:2.7.10。
如果有帮助,ipython笔记本上pyproj.pyproj_datadir
的输出为'C:\x07root\\stage\\Library\\share\\proj'
,而命令提示符为'C:\\Anaconda64\\lib\\site-packages\\pyproj\\data'
。
谢谢!
from pyproj import Proj, transform
inProj = Proj(init='epsg:3857')
outProj = Proj(init='epsg:4326')
x1,y1 = -11705274.6374,4826473.6922
x2,y2 = transform(inProj,outProj,x1,y1)
print x2,y2
答案 0 :(得分:1)
我在miniconda下运行Windows 10(64位)中的Python 2.7.11也出现此错误。我的pyproj版本是1.9.4(由运行conda list
确定)。您提到的link提出了几种解决方案:
PROJ_DIR
的环境变量,将pyproj指向其投影文件的正确位置。您必须先识别epsg文件的位置。pip install the_file.whl
从Christoph Gohlke's site安装中获取whl文件。使用这种方法,我获得了pyproj v1.9.5,它工作正常。