2022年06月時点の情報です。
Google Colab で Cartopy を使って「逆さ地図」を描画する際に試行錯誤した過程を記します。 Python はあんまりよくわかってない人で、とりあえず動く状況を探しました。
結論 : condacolab パッケージを使うといけました。
ソースビルドで pip からいれる
まずは Google Colaboratoryでバグに悩まされずにcartopyを使うの方法を試してみました。
!grep '^deb ' /etc/apt/sources.list | \
sed 's/^deb /deb-src /g' | \
tee /etc/apt/sources.list.d/deb-src.list
!apt-get -qq update
!apt-get -qq build-dep python3-cartopy
!pip uninstall -y shapely
!pip install --no-binary cartopy cartopy
記事中のパターン1の、バージョン指定なしで実行してみます。
結果を開く
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting cartopy
Downloading Cartopy-0.20.2.tar.gz (10.8 MB)
|████████████████████████████████| 10.8 MB 4.6 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... error
WARNING: Discarding https://files.pythonhosted.org/packages/f6/55/1e1c737dc9436b320deead73d1c455ddbb74b8b6992081863492f6f6378a/Cartopy-0.20.2.tar.gz#sha256=4d08c198ecaa50a6a6b109d0f14c070e813defc046a83ac5d7ab494f85599e35 (from https://pypi.org/simple/cartopy/) (requires-python:>=3.7). Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.7/dist-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmp42fe82_q Check the logs for full command output.
Downloading Cartopy-0.20.1.tar.gz (10.8 MB)
|████████████████████████████████| 10.8 MB 24.1 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... error
WARNING: Discarding https://files.pythonhosted.org/packages/fc/59/aa52698e3838f4cd0e7eaa75bd86837e9e0b05041dbdaee3cda2fffced06/Cartopy-0.20.1.tar.gz#sha256=91f87b130e2574547a20cd634498df97d797abd12dcfd0235bc0cdbcec8b05e3 (from https://pypi.org/simple/cartopy/) (requires-python:>=3.7). Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.7/dist-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpgu19nsww Check the logs for full command output.
Downloading Cartopy-0.20.0.tar.gz (10.8 MB)
|████████████████████████████████| 10.8 MB 20.2 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... error
WARNING: Discarding https://files.pythonhosted.org/packages/0f/c0/58453b036e79046d211f083880d58dcce787e7e07647ac25dc46c6555099/Cartopy-0.20.0.tar.gz#sha256=eae58aff26806e63cf115b2bce9477cedc4aa9f578c5e477b2c25cfa404f2b7a (from https://pypi.org/simple/cartopy/) (requires-python:>=3.7). Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.7/dist-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpj_wusw3f Check the logs for full command output.
Downloading Cartopy-0.19.0.post1.tar.gz (12.1 MB)
|████████████████████████████████| 12.1 MB 24.8 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Collecting pyshp>=2
Downloading pyshp-2.3.0-py2.py3-none-any.whl (46 kB)
|████████████████████████████████| 46 kB 3.7 MB/s
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/dist-packages (from cartopy) (1.21.6)
Collecting shapely>=1.5.6
Downloading Shapely-1.8.2-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.0 MB)
|████████████████████████████████| 2.0 MB 42.2 MB/s
Building wheels for collected packages: cartopy
Building wheel for cartopy (PEP 517) ... done
Created wheel for cartopy: filename=Cartopy-0.19.0.post1-cp37-cp37m-linux_x86_64.whl size=12516293 sha256=ecffcf94cfab354744946cda615d9b9188e39952f3fa52304fbbbe9d8737378f
Stored in directory: /root/.cache/pip/wheels/98/01/f7/bd10aeb96fe4b518cde5f7c4f5e12c7202f85b7353a5017847
Successfully built cartopy
Installing collected packages: shapely, pyshp, cartopy
Attempting uninstall: pyshp
Found existing installation: pyshp 1.2.12
Uninstalling pyshp-1.2.12:
Successfully uninstalled pyshp-1.2.12
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
albumentations 0.1.12 requires imgaug<0.2.7,>=0.2.5, but you have imgaug 0.2.9 which is incompatible.
Successfully installed cartopy-0.19.0.post1 pyshp-2.3.0 shapely-1.8.2
入っている Python は 3.7 ですが、よくわかりませんが cartopy 0.20.2 のインストールが requires-python:>=3.7
で失敗し、ひとつずつバージョンを下げてリトライしていき、最終的に cartopy 0.19.0.post1 がインストールされました。
Cartopy 0.19.0.post1 で逆さ地図を作ってみる
Cartopy は様々な投影法をサポートしていますが、南北を反転させるには cartopy.crs.RotatedPole
を使うか、あるいは任意の proj4_params
で投影法を指定できる cartopy.crs.Projection
を使い、斜軸(あるいは軸の回転)の投影を行う必要があります。
ただドキュメントを読むと cartopy.crs.RotatedPole
は斜軸の円筒投影っぽい感じ1です。円筒でもうまく作ればちゃんとした「逆さ地図」になると思いますが、今回は富山県の『環日本海・東アジア諸国図(通称:「逆さ地図」)』 を参考に、「富山中心正距方位図」を目指し、 cartopy.crs.Projection
を使ってみます。
しかし、 Cartopy 0.19.0 以前での cartopy.crs.Projection
はプロパティの多くが @abstractproperty
で基底クラス用のような位置付けっぽく、使用しようとするとエラーが発生したりしました。
自分がよくわかってないだけかもしれませんが、とりあえず 0.20.0 以降をインストールできないか別の方法を探ってみます。
conda !
miniconda でのインストールを試みてみます。 Google Colaboratoryにcondaをインストールしケモインフォマティクスしてみるを参考にさせてもらいました。
%env PYTHONPATH=
!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
結果を開く
env: PYTHONPATH=
--2022-06-24 13:36:41-- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8303, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 76607678 (73M) [application/x-sh]
Saving to: ‘Miniconda3-latest-Linux-x86_64.sh’
Miniconda3-latest-L 100%[===================>] 73.06M 167MB/s in 0.4s
2022-06-24 13:36:42 (167 MB/s) - ‘Miniconda3-latest-Linux-x86_64.sh’ saved [76607678/76607678]
PREFIX=/usr/local
Unpacking payload ...
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /usr/local
added / updated specs:
- _libgcc_mutex==0.1=main
- _openmp_mutex==4.5=1_gnu
- brotlipy==0.7.0=py39h27cfd23_1003
- ca-certificates==2022.3.29=h06a4308_1
- certifi==2021.10.8=py39h06a4308_2
- cffi==1.15.0=py39hd667e15_1
- charset-normalizer==2.0.4=pyhd3eb1b0_0
- colorama==0.4.4=pyhd3eb1b0_0
- conda-content-trust==0.1.1=pyhd3eb1b0_0
- conda-package-handling==1.8.1=py39h7f8727e_0
- conda==4.12.0=py39h06a4308_0
- cryptography==36.0.0=py39h9ce1e76_0
- idna==3.3=pyhd3eb1b0_0
- ld_impl_linux-64==2.35.1=h7274673_9
- libffi==3.3=he6710b0_2
- libgcc-ng==9.3.0=h5101ec6_17
- libgomp==9.3.0=h5101ec6_17
- libstdcxx-ng==9.3.0=hd4cf53a_17
- ncurses==6.3=h7f8727e_2
- openssl==1.1.1n=h7f8727e_0
- pip==21.2.4=py39h06a4308_0
- pycosat==0.6.3=py39h27cfd23_0
- pycparser==2.21=pyhd3eb1b0_0
- pyopenssl==22.0.0=pyhd3eb1b0_0
- pysocks==1.7.1=py39h06a4308_0
- python==3.9.12=h12debd9_0
- readline==8.1.2=h7f8727e_1
- requests==2.27.1=pyhd3eb1b0_0
- ruamel_yaml==0.15.100=py39h27cfd23_0
- setuptools==61.2.0=py39h06a4308_0
- six==1.16.0=pyhd3eb1b0_1
- sqlite==3.38.2=hc218d9a_0
- tk==8.6.11=h1ccaba5_0
- tqdm==4.63.0=pyhd3eb1b0_0
- tzdata==2022a=hda174b7_0
- urllib3==1.26.8=pyhd3eb1b0_0
- wheel==0.37.1=pyhd3eb1b0_0
- xz==5.2.5=h7b6447c_0
- yaml==0.2.5=h7b6447c_0
- zlib==1.2.12=h7f8727e_1
The following NEW packages will be INSTALLED:
_libgcc_mutex pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex pkgs/main/linux-64::_openmp_mutex-4.5-1_gnu
brotlipy pkgs/main/linux-64::brotlipy-0.7.0-py39h27cfd23_1003
ca-certificates pkgs/main/linux-64::ca-certificates-2022.3.29-h06a4308_1
certifi pkgs/main/linux-64::certifi-2021.10.8-py39h06a4308_2
cffi pkgs/main/linux-64::cffi-1.15.0-py39hd667e15_1
charset-normalizer pkgs/main/noarch::charset-normalizer-2.0.4-pyhd3eb1b0_0
colorama pkgs/main/noarch::colorama-0.4.4-pyhd3eb1b0_0
conda pkgs/main/linux-64::conda-4.12.0-py39h06a4308_0
conda-content-tru~ pkgs/main/noarch::conda-content-trust-0.1.1-pyhd3eb1b0_0
conda-package-han~ pkgs/main/linux-64::conda-package-handling-1.8.1-py39h7f8727e_0
cryptography pkgs/main/linux-64::cryptography-36.0.0-py39h9ce1e76_0
idna pkgs/main/noarch::idna-3.3-pyhd3eb1b0_0
ld_impl_linux-64 pkgs/main/linux-64::ld_impl_linux-64-2.35.1-h7274673_9
libffi pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng pkgs/main/linux-64::libgcc-ng-9.3.0-h5101ec6_17
libgomp pkgs/main/linux-64::libgomp-9.3.0-h5101ec6_17
libstdcxx-ng pkgs/main/linux-64::libstdcxx-ng-9.3.0-hd4cf53a_17
ncurses pkgs/main/linux-64::ncurses-6.3-h7f8727e_2
openssl pkgs/main/linux-64::openssl-1.1.1n-h7f8727e_0
pip pkgs/main/linux-64::pip-21.2.4-py39h06a4308_0
pycosat pkgs/main/linux-64::pycosat-0.6.3-py39h27cfd23_0
pycparser pkgs/main/noarch::pycparser-2.21-pyhd3eb1b0_0
pyopenssl pkgs/main/noarch::pyopenssl-22.0.0-pyhd3eb1b0_0
pysocks pkgs/main/linux-64::pysocks-1.7.1-py39h06a4308_0
python pkgs/main/linux-64::python-3.9.12-h12debd9_0
readline pkgs/main/linux-64::readline-8.1.2-h7f8727e_1
requests pkgs/main/noarch::requests-2.27.1-pyhd3eb1b0_0
ruamel_yaml pkgs/main/linux-64::ruamel_yaml-0.15.100-py39h27cfd23_0
setuptools pkgs/main/linux-64::setuptools-61.2.0-py39h06a4308_0
six pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1
sqlite pkgs/main/linux-64::sqlite-3.38.2-hc218d9a_0
tk pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0
tqdm pkgs/main/noarch::tqdm-4.63.0-pyhd3eb1b0_0
tzdata pkgs/main/noarch::tzdata-2022a-hda174b7_0
urllib3 pkgs/main/noarch::urllib3-1.26.8-pyhd3eb1b0_0
wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
yaml pkgs/main/linux-64::yaml-0.2.5-h7b6447c_0
zlib pkgs/main/linux-64::zlib-1.2.12-h7f8727e_1
Preparing transaction: done
Executing transaction: done
installation finished.
インストールされる(?) Python のバージョンごとにインストーラのシェルスクリプトが用意されていますが、 latest は Python 3.9 でした。
!python -V
Python 3.9.12
conda のアップデートもしときます。
!conda update -y -n base -c defaults conda
(略)
タイミングにもよるかもしれませんが、アップデートしとかないと Warning がでるのと、インストールされる Cartopy のバージョンが 0.18.0 でした。バージョン指定でインストールすると最新版も入りますが。
ライブラリのインストール
!conda install -y -c conda-forge cartopy
結果を開く
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /usr/local
added / updated specs:
- cartopy
The following packages will be downloaded:
package | build
---------------------------|-----------------
brotli-1.0.9 | h166bdaf_7 18 KB conda-forge
brotli-bin-1.0.9 | h166bdaf_7 19 KB conda-forge
c-ares-1.18.1 | h7f98852_0 113 KB conda-forge
ca-certificates-2022.6.15 | ha878542_0 149 KB conda-forge
cartopy-0.20.2 | py39hc85cdae_3 2.0 MB conda-forge
certifi-2022.6.15 | py39hf3d152e_0 155 KB conda-forge
conda-4.13.0 | py39hf3d152e_1 998 KB conda-forge
cycler-0.11.0 | pyhd8ed1ab_0 10 KB conda-forge
fonttools-4.33.3 | py39hb9d737c_0 1.6 MB conda-forge
freetype-2.10.4 | h0708190_1 890 KB conda-forge
geos-3.10.2 | h9c3ff4c_0 1.6 MB conda-forge
jpeg-9e | h166bdaf_1 268 KB conda-forge
keyutils-1.6.1 | h166bdaf_0 115 KB conda-forge
kiwisolver-1.4.2 | py39h295c915_0 83 KB
krb5-1.19.3 | h3790be6_0 1.4 MB conda-forge
lcms2-2.12 | hddcbb42_0 443 KB conda-forge
libblas-3.9.0 |15_linux64_openblas 12 KB conda-forge
libbrotlicommon-1.0.9 | h166bdaf_7 65 KB conda-forge
libbrotlidec-1.0.9 | h166bdaf_7 33 KB conda-forge
libbrotlienc-1.0.9 | h166bdaf_7 287 KB conda-forge
libcblas-3.9.0 |15_linux64_openblas 12 KB conda-forge
libcurl-7.82.0 | h0b77cf5_0 342 KB
libedit-3.1.20191231 | he28a2e2_2 121 KB conda-forge
libev-4.33 | h516909a_1 104 KB conda-forge
libgfortran-ng-12.1.0 | h69a702a_16 23 KB conda-forge
libgfortran5-12.1.0 | hdcd56e2_16 1.8 MB conda-forge
liblapack-3.9.0 |15_linux64_openblas 12 KB conda-forge
libnghttp2-1.46.0 | hce63b2e_0 680 KB
libopenblas-0.3.20 |pthreads_h78a6416_0 10.1 MB conda-forge
libpng-1.6.37 | h21135ba_2 306 KB conda-forge
libssh2-1.10.0 | ha56f1ee_2 233 KB conda-forge
libtiff-4.2.0 | h85742a9_0 502 KB
libwebp-base-1.2.2 | h7f98852_1 824 KB conda-forge
lz4-c-1.9.3 | h9c3ff4c_1 179 KB conda-forge
matplotlib-base-3.5.2 | py39h700656a_0 7.3 MB conda-forge
munkres-1.1.4 | pyh9f0ad1d_0 12 KB conda-forge
numpy-1.22.3 | py39hc58783e_2 6.8 MB conda-forge
olefile-0.46 | pyh9f0ad1d_1 32 KB conda-forge
packaging-21.3 | pyhd8ed1ab_0 36 KB conda-forge
pillow-7.2.0 | py39h6f3857e_2 678 KB conda-forge
proj-8.2.1 | ha227179_0 2.6 MB
pyparsing-3.0.9 | pyhd8ed1ab_0 79 KB conda-forge
pyproj-3.3.0 | py39h6de3afc_0 454 KB
pyshp-2.3.0 | pyhd8ed1ab_0 862 KB conda-forge
python-dateutil-2.8.2 | pyhd8ed1ab_0 240 KB conda-forge
python_abi-3.9 | 2_cp39 4 KB conda-forge
scipy-1.8.1 | py39he49c0e8_0 24.9 MB conda-forge
shapely-1.8.2 | py39h73b9895_1 351 KB conda-forge
six-1.16.0 | pyh6c4a22f_0 14 KB conda-forge
unicodedata2-14.0.0 | py39hb9d737c_1 498 KB conda-forge
zstd-1.4.9 | ha95c52a_0 431 KB conda-forge
------------------------------------------------------------
Total: 70.5 MB
The following NEW packages will be INSTALLED:
brotli conda-forge/linux-64::brotli-1.0.9-h166bdaf_7
brotli-bin conda-forge/linux-64::brotli-bin-1.0.9-h166bdaf_7
c-ares conda-forge/linux-64::c-ares-1.18.1-h7f98852_0
cartopy conda-forge/linux-64::cartopy-0.20.2-py39hc85cdae_3
cycler conda-forge/noarch::cycler-0.11.0-pyhd8ed1ab_0
fonttools conda-forge/linux-64::fonttools-4.33.3-py39hb9d737c_0
freetype conda-forge/linux-64::freetype-2.10.4-h0708190_1
geos conda-forge/linux-64::geos-3.10.2-h9c3ff4c_0
jpeg conda-forge/linux-64::jpeg-9e-h166bdaf_1
keyutils conda-forge/linux-64::keyutils-1.6.1-h166bdaf_0
kiwisolver pkgs/main/linux-64::kiwisolver-1.4.2-py39h295c915_0
krb5 conda-forge/linux-64::krb5-1.19.3-h3790be6_0
lcms2 conda-forge/linux-64::lcms2-2.12-hddcbb42_0
libblas conda-forge/linux-64::libblas-3.9.0-15_linux64_openblas
libbrotlicommon conda-forge/linux-64::libbrotlicommon-1.0.9-h166bdaf_7
libbrotlidec conda-forge/linux-64::libbrotlidec-1.0.9-h166bdaf_7
libbrotlienc conda-forge/linux-64::libbrotlienc-1.0.9-h166bdaf_7
libcblas conda-forge/linux-64::libcblas-3.9.0-15_linux64_openblas
libcurl pkgs/main/linux-64::libcurl-7.82.0-h0b77cf5_0
libedit conda-forge/linux-64::libedit-3.1.20191231-he28a2e2_2
libev conda-forge/linux-64::libev-4.33-h516909a_1
libgfortran-ng conda-forge/linux-64::libgfortran-ng-12.1.0-h69a702a_16
libgfortran5 conda-forge/linux-64::libgfortran5-12.1.0-hdcd56e2_16
liblapack conda-forge/linux-64::liblapack-3.9.0-15_linux64_openblas
libnghttp2 pkgs/main/linux-64::libnghttp2-1.46.0-hce63b2e_0
libopenblas conda-forge/linux-64::libopenblas-0.3.20-pthreads_h78a6416_0
libpng conda-forge/linux-64::libpng-1.6.37-h21135ba_2
libssh2 conda-forge/linux-64::libssh2-1.10.0-ha56f1ee_2
libtiff pkgs/main/linux-64::libtiff-4.2.0-h85742a9_0
libwebp-base conda-forge/linux-64::libwebp-base-1.2.2-h7f98852_1
lz4-c conda-forge/linux-64::lz4-c-1.9.3-h9c3ff4c_1
matplotlib-base conda-forge/linux-64::matplotlib-base-3.5.2-py39h700656a_0
munkres conda-forge/noarch::munkres-1.1.4-pyh9f0ad1d_0
numpy conda-forge/linux-64::numpy-1.22.3-py39hc58783e_2
olefile conda-forge/noarch::olefile-0.46-pyh9f0ad1d_1
packaging conda-forge/noarch::packaging-21.3-pyhd8ed1ab_0
pillow conda-forge/linux-64::pillow-7.2.0-py39h6f3857e_2
proj pkgs/main/linux-64::proj-8.2.1-ha227179_0
pyparsing conda-forge/noarch::pyparsing-3.0.9-pyhd8ed1ab_0
pyproj pkgs/main/linux-64::pyproj-3.3.0-py39h6de3afc_0
pyshp conda-forge/noarch::pyshp-2.3.0-pyhd8ed1ab_0
python-dateutil conda-forge/noarch::python-dateutil-2.8.2-pyhd8ed1ab_0
python_abi conda-forge/linux-64::python_abi-3.9-2_cp39
scipy conda-forge/linux-64::scipy-1.8.1-py39he49c0e8_0
shapely conda-forge/linux-64::shapely-1.8.2-py39h73b9895_1
six conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
unicodedata2 conda-forge/linux-64::unicodedata2-14.0.0-py39hb9d737c_1
zstd conda-forge/linux-64::zstd-1.4.9-ha95c52a_0
The following packages will be UPDATED:
ca-certificates pkgs/main::ca-certificates-2022.4.26-~ --> conda-forge::ca-certificates-2022.6.15-ha878542_0
conda pkgs/main::conda-4.13.0-py39h06a4308_0 --> conda-forge::conda-4.13.0-py39hf3d152e_1
The following packages will be SUPERSEDED by a higher-priority channel:
certifi pkgs/main::certifi-2022.6.15-py39h06a~ --> conda-forge::certifi-2022.6.15-py39hf3d152e_0
Downloading and Extracting Packages
brotli-bin-1.0.9 | 19 KB | : 100% 1.0/1 [00:00<00:00, 11.49it/s]
libedit-3.1.20191231 | 121 KB | : 100% 1.0/1 [00:00<00:00, 12.36it/s]
freetype-2.10.4 | 890 KB | : 100% 1.0/1 [00:00<00:00, 4.11it/s]
libtiff-4.2.0 | 502 KB | : 100% 1.0/1 [00:00<00:00, 7.41it/s]
fonttools-4.33.3 | 1.6 MB | : 100% 1.0/1 [00:00<00:00, 1.71it/s]
libgfortran-ng-12.1. | 23 KB | : 100% 1.0/1 [00:00<00:00, 24.31it/s]
libbrotlienc-1.0.9 | 287 KB | : 100% 1.0/1 [00:00<00:00, 11.39it/s]
libssh2-1.10.0 | 233 KB | : 100% 1.0/1 [00:00<00:00, 8.18it/s]
pyparsing-3.0.9 | 79 KB | : 100% 1.0/1 [00:00<00:00, 14.78it/s]
matplotlib-base-3.5. | 7.3 MB | : 100% 1.0/1 [00:01<00:00, 1.54s/it]
libcblas-3.9.0 | 12 KB | : 100% 1.0/1 [00:00<00:00, 26.05it/s]
python_abi-3.9 | 4 KB | : 100% 1.0/1 [00:00<00:00, 27.96it/s]
packaging-21.3 | 36 KB | : 100% 1.0/1 [00:00<00:00, 22.94it/s]
cartopy-0.20.2 | 2.0 MB | : 100% 1.0/1 [00:00<00:00, 2.57it/s]
libbrotlidec-1.0.9 | 33 KB | : 100% 1.0/1 [00:00<00:00, 29.51it/s]
unicodedata2-14.0.0 | 498 KB | : 100% 1.0/1 [00:00<00:00, 9.35it/s]
pyproj-3.3.0 | 454 KB | : 100% 1.0/1 [00:00<00:00, 6.37it/s]
ca-certificates-2022 | 149 KB | : 100% 1.0/1 [00:00<00:00, 15.54it/s]
cycler-0.11.0 | 10 KB | : 100% 1.0/1 [00:00<00:00, 26.56it/s]
munkres-1.1.4 | 12 KB | : 100% 1.0/1 [00:00<00:00, 20.45it/s]
libblas-3.9.0 | 12 KB | : 100% 1.0/1 [00:00<00:00, 21.05it/s]
liblapack-3.9.0 | 12 KB | : 100% 1.0/1 [00:00<00:00, 20.16it/s]
numpy-1.22.3 | 6.8 MB | : 100% 1.0/1 [00:01<00:00, 1.93s/it]
six-1.16.0 | 14 KB | : 100% 1.0/1 [00:00<00:00, 34.20it/s]
libgfortran5-12.1.0 | 1.8 MB | : 100% 1.0/1 [00:00<00:00, 2.64it/s]
jpeg-9e | 268 KB | : 100% 1.0/1 [00:00<00:00, 9.63it/s]
keyutils-1.6.1 | 115 KB | : 100% 1.0/1 [00:00<00:00, 17.34it/s]
kiwisolver-1.4.2 | 83 KB | : 100% 1.0/1 [00:00<00:00, 15.70it/s]
pyshp-2.3.0 | 862 KB | : 100% 1.0/1 [00:00<00:00, 3.19it/s]
libcurl-7.82.0 | 342 KB | : 100% 1.0/1 [00:00<00:00, 13.69it/s]
lcms2-2.12 | 443 KB | : 100% 1.0/1 [00:00<00:00, 8.50it/s]
libbrotlicommon-1.0. | 65 KB | : 100% 1.0/1 [00:00<00:00, 17.27it/s]
libev-4.33 | 104 KB | : 100% 1.0/1 [00:00<00:00, 20.60it/s]
proj-8.2.1 | 2.6 MB | : 100% 1.0/1 [00:00<00:00, 4.77it/s]
brotli-1.0.9 | 18 KB | : 100% 1.0/1 [00:00<00:00, 24.29it/s]
pillow-7.2.0 | 678 KB | : 100% 1.0/1 [00:00<00:00, 5.60it/s]
libpng-1.6.37 | 306 KB | : 100% 1.0/1 [00:00<00:00, 8.02it/s]
geos-3.10.2 | 1.6 MB | : 100% 1.0/1 [00:00<00:00, 1.56it/s]
libnghttp2-1.46.0 | 680 KB | : 100% 1.0/1 [00:00<00:00, 8.44it/s]
olefile-0.46 | 32 KB | : 100% 1.0/1 [00:00<00:00, 17.93it/s]
krb5-1.19.3 | 1.4 MB | : 100% 1.0/1 [00:00<00:00, 2.08it/s]
python-dateutil-2.8. | 240 KB | : 100% 1.0/1 [00:00<00:00, 10.68it/s]
certifi-2022.6.15 | 155 KB | : 100% 1.0/1 [00:00<00:00, 15.21it/s]
conda-4.13.0 | 998 KB | : 100% 1.0/1 [00:00<00:00, 2.13it/s]
libopenblas-0.3.20 | 10.1 MB | : 100% 1.0/1 [00:02<00:00, 2.53s/it]
shapely-1.8.2 | 351 KB | : 100% 1.0/1 [00:00<00:00, 6.32it/s]
zstd-1.4.9 | 431 KB | : 100% 1.0/1 [00:00<00:00, 7.58it/s]
c-ares-1.18.1 | 113 KB | : 100% 1.0/1 [00:00<00:00, 13.49it/s]
scipy-1.8.1 | 24.9 MB | : 100% 1.0/1 [00:05<00:00, 5.28s/it]
lz4-c-1.9.3 | 179 KB | : 100% 1.0/1 [00:00<00:00, 12.87it/s]
libwebp-base-1.2.2 | 824 KB | : 100% 1.0/1 [00:00<00:00, 4.59it/s]
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
cartopy-0.20.2
/ proj-8.2.1
/ pyproj-3.3.0
などがインストールされました。
import できるように
Python のバージョンが 3.9 だったので
import sys
sys.path.append(r"/usr/local/lib/python3.9/site-packages")
pyproj の import でエラー
Cartopy 0.20.0 以上から Pyproj が依存関係にあり、 Cartopy を読み込むときに Pyproj を呼び出しますが、エラーが発生します。更に確認すると Cartopy 関係なく Pyproj 単体の読み込みでもエラーがでます。
import pyproj
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-98cb605ea9de> in <module>()
----> 1 import pyproj
1 frames
/usr/local/lib/python3.9/site-packages/pyproj/network.py in <module>()
8 import certifi
9
---> 10 from pyproj._network import ( # noqa: F401 pylint: disable=unused-import
11 _set_ca_bundle_path,
12 is_network_enabled,
ModuleNotFoundError: No module named 'pyproj._network'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
これが Pyproj の特定のバージョンにおける問題なのか、よくわかりません。検索してみると Visual C++ Redistributable Package 絡みっぽい回答はありましたが、 Windows でもないし。
最新の Pyproj 3.3.1 にアップデートしても同様のエラーが生じました。このイシュー自体比較的最近のものなので、もしかするとそのうち解消するかもしれません。
condacolab をつかう
もう少し情報を集めていると Google ColaboratoryにminiforgeをインストールしてRDkitを走らせたという記事内で condacolab を使ったインストールが紹介されていました。
!pip install -q condacolab
import condacolab
condacolab.install_miniforge()
⏬ Downloading https://github.com/jaimergp/miniforge/releases/latest/download/Miniforge-colab-Linux-x86_64.sh...
📦 Installing...
📌 Adjusting configuration...
🩹 Patching environment...
⏲ Done in 0:00:23
🔁 Restarting kernel...
途中でカーネルの再起動のためセッションが再起動しますが、問題ありません。
!conda update -y -n base -c defaults conda
(略)
ライブラリのインストール
!conda install -y -c conda-forge cartopy
結果を開く
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /usr/local
added / updated specs:
- cartopy
The following packages will be downloaded:
package | build
---------------------------|-----------------
brotli-1.0.9 | h166bdaf_7 18 KB conda-forge
brotli-bin-1.0.9 | h166bdaf_7 19 KB conda-forge
c-ares-1.18.1 | h7f98852_0 113 KB conda-forge
ca-certificates-2022.6.15 | ha878542_0 149 KB conda-forge
cartopy-0.20.2 | py37h9a08e6e_0 1.7 MB conda-forge
certifi-2022.6.15 | py37h89c1867_0 155 KB conda-forge
conda-4.13.0 | py37h89c1867_1 989 KB conda-forge
cudatoolkit-11.1.1 | ha002fc5_10 1.20 GB conda-forge
cycler-0.11.0 | pyhd8ed1ab_0 10 KB conda-forge
fonttools-4.33.3 | py37h540881e_0 1.6 MB conda-forge
freetype-2.10.4 | h0708190_1 890 KB conda-forge
geos-3.10.1 | h9c3ff4c_1 1.4 MB conda-forge
jbig-2.1 | h7f98852_2003 43 KB conda-forge
jpeg-9e | h166bdaf_1 268 KB conda-forge
keyutils-1.6.1 | h166bdaf_0 115 KB conda-forge
kiwisolver-1.4.2 | py37h7cecad7_1 73 KB conda-forge
krb5-1.19.3 | h3790be6_0 1.4 MB conda-forge
lcms2-2.12 | hddcbb42_0 443 KB conda-forge
lerc-2.2.1 | h9c3ff4c_0 213 KB conda-forge
libblas-3.9.0 |15_linux64_openblas 12 KB conda-forge
libbrotlicommon-1.0.9 | h166bdaf_7 65 KB conda-forge
libbrotlidec-1.0.9 | h166bdaf_7 33 KB conda-forge
libbrotlienc-1.0.9 | h166bdaf_7 287 KB conda-forge
libcblas-3.9.0 |15_linux64_openblas 12 KB conda-forge
libcurl-7.79.1 | h2574ce0_1 335 KB conda-forge
libdeflate-1.7 | h7f98852_5 67 KB conda-forge
libedit-3.1.20191231 | he28a2e2_2 121 KB conda-forge
libev-4.33 | h516909a_1 104 KB conda-forge
libgfortran-ng-12.1.0 | h69a702a_16 23 KB conda-forge
libgfortran5-12.1.0 | hdcd56e2_16 1.8 MB conda-forge
liblapack-3.9.0 |15_linux64_openblas 12 KB conda-forge
libnghttp2-1.43.0 | h812cca2_1 790 KB conda-forge
libopenblas-0.3.20 |pthreads_h78a6416_0 10.1 MB conda-forge
libpng-1.6.37 | h21135ba_2 306 KB conda-forge
libssh2-1.10.0 | ha56f1ee_2 233 KB conda-forge
libtiff-4.3.0 | hf544144_1 668 KB conda-forge
libwebp-base-1.2.2 | h7f98852_1 824 KB conda-forge
lz4-c-1.9.3 | h9c3ff4c_1 179 KB conda-forge
matplotlib-base-3.5.2 | py37hc347a89_0 7.3 MB conda-forge
munkres-1.1.4 | pyh9f0ad1d_0 12 KB conda-forge
numpy-1.21.6 | py37h976b520_0 6.1 MB conda-forge
olefile-0.46 | pyh9f0ad1d_1 32 KB conda-forge
openjpeg-2.4.0 | hb52868f_1 444 KB conda-forge
openssl-1.1.1o | h166bdaf_0 2.1 MB conda-forge
packaging-21.3 | pyhd8ed1ab_0 36 KB conda-forge
pillow-8.3.2 | py37h0f21c89_0 692 KB conda-forge
proj-8.2.0 | h277dcde_0 3.0 MB conda-forge
pyparsing-3.0.9 | pyhd8ed1ab_0 79 KB conda-forge
pyproj-3.2.1 | py37hb589d83_5 526 KB conda-forge
pyshp-2.3.0 | pyhd8ed1ab_0 862 KB conda-forge
python-dateutil-2.8.2 | pyhd8ed1ab_0 240 KB conda-forge
scipy-1.7.3 | py37hf2a6cf1_0 21.8 MB conda-forge
shapely-1.8.0 | py37h9b0f7a3_4 373 KB conda-forge
six-1.16.0 | pyh6c4a22f_0 14 KB conda-forge
typing-extensions-4.2.0 | hd8ed1ab_1 8 KB conda-forge
typing_extensions-4.2.0 | pyha770c72_1 27 KB conda-forge
unicodedata2-14.0.0 | py37h540881e_1 496 KB conda-forge
zstd-1.5.0 | ha95c52a_0 490 KB conda-forge
------------------------------------------------------------
Total: 1.27 GB
The following NEW packages will be INSTALLED:
brotli conda-forge/linux-64::brotli-1.0.9-h166bdaf_7
brotli-bin conda-forge/linux-64::brotli-bin-1.0.9-h166bdaf_7
c-ares conda-forge/linux-64::c-ares-1.18.1-h7f98852_0
cartopy conda-forge/linux-64::cartopy-0.20.2-py37h9a08e6e_0
cudatoolkit conda-forge/linux-64::cudatoolkit-11.1.1-ha002fc5_10
cycler conda-forge/noarch::cycler-0.11.0-pyhd8ed1ab_0
fonttools conda-forge/linux-64::fonttools-4.33.3-py37h540881e_0
freetype conda-forge/linux-64::freetype-2.10.4-h0708190_1
geos conda-forge/linux-64::geos-3.10.1-h9c3ff4c_1
jbig conda-forge/linux-64::jbig-2.1-h7f98852_2003
jpeg conda-forge/linux-64::jpeg-9e-h166bdaf_1
keyutils conda-forge/linux-64::keyutils-1.6.1-h166bdaf_0
kiwisolver conda-forge/linux-64::kiwisolver-1.4.2-py37h7cecad7_1
krb5 conda-forge/linux-64::krb5-1.19.3-h3790be6_0
lcms2 conda-forge/linux-64::lcms2-2.12-hddcbb42_0
lerc conda-forge/linux-64::lerc-2.2.1-h9c3ff4c_0
libblas conda-forge/linux-64::libblas-3.9.0-15_linux64_openblas
libbrotlicommon conda-forge/linux-64::libbrotlicommon-1.0.9-h166bdaf_7
libbrotlidec conda-forge/linux-64::libbrotlidec-1.0.9-h166bdaf_7
libbrotlienc conda-forge/linux-64::libbrotlienc-1.0.9-h166bdaf_7
libcblas conda-forge/linux-64::libcblas-3.9.0-15_linux64_openblas
libcurl conda-forge/linux-64::libcurl-7.79.1-h2574ce0_1
libdeflate conda-forge/linux-64::libdeflate-1.7-h7f98852_5
libedit conda-forge/linux-64::libedit-3.1.20191231-he28a2e2_2
libev conda-forge/linux-64::libev-4.33-h516909a_1
libgfortran-ng conda-forge/linux-64::libgfortran-ng-12.1.0-h69a702a_16
libgfortran5 conda-forge/linux-64::libgfortran5-12.1.0-hdcd56e2_16
liblapack conda-forge/linux-64::liblapack-3.9.0-15_linux64_openblas
libnghttp2 conda-forge/linux-64::libnghttp2-1.43.0-h812cca2_1
libopenblas conda-forge/linux-64::libopenblas-0.3.20-pthreads_h78a6416_0
libpng conda-forge/linux-64::libpng-1.6.37-h21135ba_2
libssh2 conda-forge/linux-64::libssh2-1.10.0-ha56f1ee_2
libtiff conda-forge/linux-64::libtiff-4.3.0-hf544144_1
libwebp-base conda-forge/linux-64::libwebp-base-1.2.2-h7f98852_1
lz4-c conda-forge/linux-64::lz4-c-1.9.3-h9c3ff4c_1
matplotlib-base conda-forge/linux-64::matplotlib-base-3.5.2-py37hc347a89_0
munkres conda-forge/noarch::munkres-1.1.4-pyh9f0ad1d_0
numpy conda-forge/linux-64::numpy-1.21.6-py37h976b520_0
olefile conda-forge/noarch::olefile-0.46-pyh9f0ad1d_1
openjpeg conda-forge/linux-64::openjpeg-2.4.0-hb52868f_1
packaging conda-forge/noarch::packaging-21.3-pyhd8ed1ab_0
pillow conda-forge/linux-64::pillow-8.3.2-py37h0f21c89_0
proj conda-forge/linux-64::proj-8.2.0-h277dcde_0
pyparsing conda-forge/noarch::pyparsing-3.0.9-pyhd8ed1ab_0
pyproj conda-forge/linux-64::pyproj-3.2.1-py37hb589d83_5
pyshp conda-forge/noarch::pyshp-2.3.0-pyhd8ed1ab_0
python-dateutil conda-forge/noarch::python-dateutil-2.8.2-pyhd8ed1ab_0
scipy conda-forge/linux-64::scipy-1.7.3-py37hf2a6cf1_0
shapely conda-forge/linux-64::shapely-1.8.0-py37h9b0f7a3_4
six conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
typing-extensions conda-forge/noarch::typing-extensions-4.2.0-hd8ed1ab_1
typing_extensions conda-forge/noarch::typing_extensions-4.2.0-pyha770c72_1
unicodedata2 conda-forge/linux-64::unicodedata2-14.0.0-py37h540881e_1
zstd conda-forge/linux-64::zstd-1.5.0-ha95c52a_0
The following packages will be UPDATED:
ca-certificates pkgs/main::ca-certificates-2022.4.26-~ --> conda-forge::ca-certificates-2022.6.15-ha878542_0
conda pkgs/main::conda-4.13.0-py37h06a4308_0 --> conda-forge::conda-4.13.0-py37h89c1867_1
The following packages will be SUPERSEDED by a higher-priority channel:
certifi pkgs/main::certifi-2022.6.15-py37h06a~ --> conda-forge::certifi-2022.6.15-py37h89c1867_0
openssl pkgs/main::openssl-1.1.1o-h7f8727e_0 --> conda-forge::openssl-1.1.1o-h166bdaf_0
Downloading and Extracting Packages
openssl-1.1.1o | 2.1 MB | : 100% 1.0/1 [00:00<00:00, 2.15it/s]
certifi-2022.6.15 | 155 KB | : 100% 1.0/1 [00:00<00:00, 15.07it/s]
libtiff-4.3.0 | 668 KB | : 100% 1.0/1 [00:00<00:00, 5.79it/s]
libdeflate-1.7 | 67 KB | : 100% 1.0/1 [00:00<00:00, 17.43it/s]
unicodedata2-14.0.0 | 496 KB | : 100% 1.0/1 [00:00<00:00, 8.62it/s]
zstd-1.5.0 | 490 KB | : 100% 1.0/1 [00:00<00:00, 7.83it/s]
conda-4.13.0 | 989 KB | : 100% 1.0/1 [00:00<00:00, 3.15it/s]
geos-3.10.1 | 1.4 MB | : 100% 1.0/1 [00:00<00:00, 2.47it/s]
libssh2-1.10.0 | 233 KB | : 100% 1.0/1 [00:00<00:00, 8.97it/s]
krb5-1.19.3 | 1.4 MB | : 100% 1.0/1 [00:00<00:00, 2.96it/s]
jbig-2.1 | 43 KB | : 100% 1.0/1 [00:00<00:00, 9.27it/s]
lerc-2.2.1 | 213 KB | : 100% 1.0/1 [00:00<00:00, 8.56it/s]
pyparsing-3.0.9 | 79 KB | : 100% 1.0/1 [00:00<00:00, 17.33it/s]
c-ares-1.18.1 | 113 KB | : 100% 1.0/1 [00:00<00:00, 14.86it/s]
cartopy-0.20.2 | 1.7 MB | : 100% 1.0/1 [00:00<00:00, 2.93it/s]
munkres-1.1.4 | 12 KB | : 100% 1.0/1 [00:00<00:00, 24.07it/s]
pyproj-3.2.1 | 526 KB | : 100% 1.0/1 [00:00<00:00, 5.65it/s]
libedit-3.1.20191231 | 121 KB | : 100% 1.0/1 [00:00<00:00, 13.50it/s]
pyshp-2.3.0 | 862 KB | : 100% 1.0/1 [00:00<00:00, 3.13it/s]
brotli-1.0.9 | 18 KB | : 100% 1.0/1 [00:00<00:00, 25.66it/s]
libcblas-3.9.0 | 12 KB | : 100% 1.0/1 [00:00<00:00, 24.05it/s]
olefile-0.46 | 32 KB | : 100% 1.0/1 [00:00<00:00, 24.40it/s]
numpy-1.21.6 | 6.1 MB | : 100% 1.0/1 [00:01<00:00, 1.57s/it]
typing-extensions-4. | 8 KB | : 100% 1.0/1 [00:00<00:00, 24.57it/s]
libgfortran-ng-12.1. | 23 KB | : 100% 1.0/1 [00:00<00:00, 20.82it/s]
proj-8.2.0 | 3.0 MB | : 100% 1.0/1 [00:00<00:00, 1.52it/s]
libev-4.33 | 104 KB | : 100% 1.0/1 [00:00<00:00, 15.16it/s]
matplotlib-base-3.5. | 7.3 MB | : 100% 1.0/1 [00:01<00:00, 1.56s/it]
cycler-0.11.0 | 10 KB | : 100% 1.0/1 [00:00<00:00, 16.14it/s]
freetype-2.10.4 | 890 KB | : 100% 1.0/1 [00:00<00:00, 4.69it/s]
typing_extensions-4. | 27 KB | : 100% 1.0/1 [00:00<00:00, 24.26it/s]
libopenblas-0.3.20 | 10.1 MB | : 100% 1.0/1 [00:02<00:00, 2.15s/it]
libbrotlicommon-1.0. | 65 KB | : 100% 1.0/1 [00:00<00:00, 21.71it/s]
pillow-8.3.2 | 692 KB | : 100% 1.0/1 [00:00<00:00, 4.64it/s]
python-dateutil-2.8. | 240 KB | : 100% 1.0/1 [00:00<00:00, 13.37it/s]
shapely-1.8.0 | 373 KB | : 100% 1.0/1 [00:00<00:00, 7.13it/s]
libcurl-7.79.1 | 335 KB | : 100% 1.0/1 [00:00<00:00, 10.64it/s]
kiwisolver-1.4.2 | 73 KB | : 100% 1.0/1 [00:00<00:00, 19.03it/s]
lcms2-2.12 | 443 KB | : 100% 1.0/1 [00:00<00:00, 8.16it/s]
cudatoolkit-11.1.1 | 1.20 GB | : 100% 1.0/1 [03:13<00:00, 193.95s/it]
brotli-bin-1.0.9 | 19 KB | : 100% 1.0/1 [00:00<00:00, 14.84it/s]
libgfortran5-12.1.0 | 1.8 MB | : 100% 1.0/1 [00:00<00:00, 1.81it/s]
openjpeg-2.4.0 | 444 KB | : 100% 1.0/1 [00:00<00:00, 5.99it/s]
six-1.16.0 | 14 KB | : 100% 1.0/1 [00:00<00:00, 17.78it/s]
keyutils-1.6.1 | 115 KB | : 100% 1.0/1 [00:00<00:00, 14.39it/s]
lz4-c-1.9.3 | 179 KB | : 100% 1.0/1 [00:00<00:00, 10.71it/s]
libnghttp2-1.43.0 | 790 KB | : 100% 1.0/1 [00:00<00:00, 4.78it/s]
fonttools-4.33.3 | 1.6 MB | : 100% 1.0/1 [00:00<00:00, 1.94it/s]
packaging-21.3 | 36 KB | : 100% 1.0/1 [00:00<00:00, 15.50it/s]
libbrotlienc-1.0.9 | 287 KB | : 100% 1.0/1 [00:00<00:00, 12.23it/s]
jpeg-9e | 268 KB | : 100% 1.0/1 [00:00<00:00, 9.68it/s]
liblapack-3.9.0 | 12 KB | : 100% 1.0/1 [00:00<00:00, 21.43it/s]
libpng-1.6.37 | 306 KB | : 100% 1.0/1 [00:00<00:00, 9.20it/s]
libwebp-base-1.2.2 | 824 KB | : 100% 1.0/1 [00:00<00:00, 4.87it/s]
scipy-1.7.3 | 21.8 MB | : 100% 1.0/1 [00:04<00:00, 4.61s/it]
libblas-3.9.0 | 12 KB | : 100% 1.0/1 [00:00<00:00, 18.85it/s]
ca-certificates-2022 | 149 KB | : 100% 1.0/1 [00:00<00:00, 15.58it/s]
libbrotlidec-1.0.9 | 33 KB | : 100% 1.0/1 [00:00<00:00, 18.37it/s]
Preparing transaction: done
Verifying transaction: done
Executing transaction: \ By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.htmldone
cartopy-0.20.2
/ proj-8.2.0
/ pyproj-3.2.1
などがインストールされました。
実行した時期と、そのときのバージョンの差異なのかよくわかりませんが、今度は Pyproj の読み込みでエラーは生じませんでした。
なんやかんやあって
作図のパラメータ決定などは別の記事に書きます。
-
cylindrical topology とはあるけど、円筒の何かということは書いてない ↩