[PYTHON] Install pyproj on Jetson / RasPi

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

background

What was wrong

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.

PROJ version

The stabilizer of pyproj seems to be 2.6.1 now (2020/10/07). http://pyproj4.github.io/pyproj/stable/

image.png

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/) image.png

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.

Installation method

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.

Install PROJ

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)

Install pyproj

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.

A method that may be easier to realize later

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: image.png

Would you like to clone pyproj from github and build it directly? (https://github.com/pyproj4/pyproj)

end

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

Install pyproj on Jetson / RasPi
How to install OpenCV on Jetson Nano Python
Install mecab on Marvericks
Install Tensorflow on Mac
Install TensorFlow on Ubuntu
Install python on WSL
Install Faiss on CentOS 7
Install pyenv on mac
Install pip on Mavericks
Install Python on Pidora.
Install mongodb on termux
Install Scrapy on python3
Install docker on Fedora31
Install numba on CentOS 7.2
Install Python on Mac
Install Python 3 on Mac
Install Plone (4.3.6) on MacOSX (10.10.3)
Install Python3.4 on CentOS 6.6
Install JModelica on Ubuntu
Install Anaconda on Windows 10
Install numpy on Marvericks
Install python on windows
Install enebular-agent on Chromebook
Install pycuda on Windows10
Install mecab-python on CentOS
Install Python 2.7.3 on CentOS 5.4
Install pygraphviz on Windows 10
Install Python 3.3 on Ubuntu 12.04
Install Chainer 1.5.0 on Windows
Install Python 3.4 on Mac
Install Caffe on Mac
Install Theano on Ubuntu 12.04
Install pyenv on OSX
Install mecab on mac
Install awscli on centos7
Install angr on Ubuntu 18.04
Install Chainer on CentOS 6.7
Install mecab-python on Mac
Install pip / pip3 on Ubuntu
Install Python 3.6 on Docker
Install octave_kernel on Jupyter [additional]
Install Numpy on virtualenv on Windows
Install Minecraft on Arch Linux
Install cvxopt on 64bit Anaconda
Install Scrapy on Raspbian (Jessie)
Install Python 3.8 on RHEL 8 (AppStream)
Install Linux on your Chromebox
Install pygame on python3.4 on mac
Install tomcat 9 on Cent OS 8
Install cvxpy on windows, Anaconda
Install ImageMagick-6.2.x series on CentOS7.7
Install Python 3.8 on CentOS 7 (SCL)
Install the JDK on Linux
Install module on Anaconda (Mac)
Install OpenPose on mac (Catalina)
Install MariaDB on Sakura's VPS
Install numba on your Mac
Install pandas 0.14 on python3.4 [on Mac]
Install OpenCV on Ubuntu + python
Install Chainer 1.6 (GPU) on Windows 7.
wsl Install PostgreSQL on Ubuntu 18.04