I'm addicted to installing a new pyproj (ver2.1 or higher) with Docker with Jetson Nano's docker build, so make a note of it. pyproj is a very useful tool that can be used to transform datums. (cf.) My past posts -[Python] Conversion from WGS84 to plane rectangular coordinate system
Until now, I used to write `` `pyproj == 2.6.1.post1``` in requirementx.txt for pip3. It worked on WSL1 (ubuntu18.04) for laptops and Docker image (ubuntu18.04 base) for CI / CD on Google Cloud Platform. I tried to do the same with Jetson Nano (Jetpak4.4? Ubuntu18.04) or docker on raspberry pi4, but it didn't work with this requirements.txt, probably because the CPU is different from ARMv8.
The stabilizer of pyproj seems to be 2.6.1 now (2020/10/07). http://pyproj4.github.io/pyproj/stable/
As you can see here, PROJ must have 6.2.0 or higher installed. The problem was that I wasn't able to install a new library called PROJ that pyproj uses.
(cf.) PROJ (https://proj.org/)
If you just want to install PROJ and libproj.a, you can do it below. Actually, it is written in Installation instructions of the head family.
$ sudo apt install proj-bin
$ sudo apt install libproj-dev
However, the problem is that even if you do this, only the old ones will be included.
$ proj
Rel. 4.9.3, 15 August 2016
usage: proj [ -bCeEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]
$ ldd `which proj` | grep libproj
libproj.so.12 => /usr/lib/x86_64-linux-gnu/libproj.so.12 (0x00007f2adad70000)
Even in this state, if `` `pyproj == 1.9.6``` and pyproj are also old, pip3 install can be done. However, my code used the API of pyproj> = 2.1. I don't want to rewrite the code, so I decided to do my best to install pyproj.
After all, if I build the latest version of PROJ from source, install it, and then pip3, I get pyproj == 2.6.1.post1. This is the installation of PROJ, but it's pretty good.
The point is --Install the libraries required for PROJ before building --libproj.a will be installed in / usr / local / lib, so include it in your LD_LIBRARY_PATH. In my environment, this variable was empty.
$ apt install -y \
zlib1g-dev libsqlite3-dev pkg-config sqlite3 libcurl4-gnutls-dev libtiff5-dev
$ wget https://download.osgeo.org/proj/proj-7.1.1.tar.gz
$ tar zxvf proj-7.1.1.tar.gz
# cd proj-7.1.1 && ./configure && make && make install
$ export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
The new one has arrived safely.
$ proj
Rel. 7.0.1, May 1st, 2020
usage: proj [-bdeEfiIlmorsStTvVwW [args]] [+opt[=arg] ...] [file ...]
$ ldd `which proj` | grep libproj
libproj.so.19 => /usr/local/lib/libproj.so.19 (0x0000007fad95b000)
As you can see by running pip3, you need to set an environment variable called PROJ_DIR. I was OK below. It seemed to refer to $ PROJ_DIR / lib / libproj.a
and
$ PROJ_DIR / bin / proj```.
$ export PROJ_DIR=/usr/local/
$ pip3 install pyproj==2.6.1.post1
I wrote this content in a Dockerfile and successfully built docker. docker build took a long time. Building from source is hard.
There were various dependencies for building PROJ and installing pyproj, but maybe I should have referred to the Dockerfile in the source of pyproj. Is it really nowadays to distribute with docker?
The https://github.com/OSGeo/PROJ/blob/master/Dockerfile has the following:
Would you like to clone pyproj from github and build it directly? (https://github.com/pyproj4/pyproj)
So, I've successfully achieved my goal (using pyproj in docker build / run on ARMv8). There is no TODO in particular, but I'm sure it will be a happy world where you can easily enter with apt or pip in the future. I'm sorry for this application, but for the time being, that's all for today.
Recommended Posts