I am trying to install pyproj on a remote server running anaconda python 2.7.15 on Ubuntu 16.04. After running conda install -c conda-forge pyproj
(first listed option at https://anaconda.org/conda-forge/pyproj), the package installs successfully (pyproj 2.0.2). However, upon running my program I get the following traceback:
Traceback (most recent call last):
File "run_qc_worker.py", line 1288, in <module>
GC.make_metadata_caches() # For percentiles check
File "/home/ubuntu/qc-mem/qc/lib/global_class.py", line 384, in make_metadata_caches
mercator_arr = self.proj_arr(lat_lon_arr) # project to x/y
File "/home/ubuntu/qc-mem/qc/lib/global_class.py", line 421, in proj_arr
inproj = Proj(init='epsg:4326') # WGS 84
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/pyproj/__init__.py", line 322, in __init__
self.crs = CRS.from_user_input(projparams if projparams is not None else kwargs)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/pyproj/crs.py", line 224, in from_user_input
return cls(**value)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/pyproj/crs.py", line 146, in __init__
super(CRS, self).__init__(projstring)
File "pyproj/_crs.pyx", line 307, in pyproj._crs._CRS.__init__
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/pyproj/datadir.py", line 62, in get_data_dir
"Valid PROJ.4 data directory not found."
pyproj.exceptions.DataDirError: Valid PROJ.4 data directory not found.Either set the path using the environmental variable PROJ_LIB or with `pyproj.datadir.set_data_dir`.
In my python script, I import with from pyproj import Proj, transform
, and the relevant lines of code are:
inproj = Proj(init='epsg:4326') # WGS 84
outproj = Proj(init='epsg:3857') # WGS 84 / Pseudo-Mercator
Apparently, pyproj is unable to find a data
directory. Searching the directory at
~/anaconda2/lib/python2.7/site-packages/pyproj
, I confirmed there is no data
directory. I have another server with an installation of pyproj on anaconda3 that does contain a data
directory (with an epsg
file). I copied this directory to the anaconda2 server, and declared the path using the environment variable as instructed in the traceback:
export PROJ_LIB=~/anaconda2/lib/python2.7/site-packages/pyproj/data
I still get the same error traceback.
I cannot find a data
directory on the github repo for pyproj (https://github.com/pyproj4/pyproj/).
How can I resolve this error?