Linux 上 ArcGIS Server 的 Python 3 运行时自动配置
操作系统环境Redhat Enterprise Linux 9.2,conda环境选择的miniconda3,已经提前安装好了ArcGIS Server for Linux 10.7.1,并且正常运行。
下面是arcgis-server-arcpy3.sh的内容:
#!/bin/bash
# 切换到conda-install目录,里面有虚拟环境模板文件arcgispro-py3.yaml
cd /oakdata/conda-install
# 从清华大学源下载miniconda3安装文件
wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 静默安装miniconda3到目录 /oakdata/miniconda3
bash Miniconda3-latest-Linux-x86_64.sh -b -u -p /oakdata/miniconda3
# 初始化miniconda3
eval "$('/oakdata/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
conda config --set auto_activate_base false
export PATH="/oakdata/miniconda3/bin:$PATH"
# 根据当前目录下的模板文件arcgispro-py3.yaml,创建环境arcgispro-py3
conda env create -f arcgispro-py3.yaml
# 配置arcgis server环境变量,启动arcgispro-py3环境
export ARCGISHOME="/oakdata/arcgis-server/arcgis/server"
source /oakdata/miniconda3/bin/activate arcgispro-py3
运行完毕之后,运行python,加载一下arcpy试试,如果不报错,就是配置成功
(arcgispro-py3) [megusta@server conda-install]$ python
# Python 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 23:51:54)
# [GCC 7.3.0] on linux
# Type "help", "copyright", "credits" or "license" for more information.
# >>> import arcpy
# >>>
下面是arcgispro-py3.yaml模板文件的内容:
name: arcgispro-py3
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- defaults
- esri
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- arcgis=1.7.1=py36h39e3cac_969
- arcgis-server-py3=10.7.1=py36_11595
- blas=1.0=mkl
- bleach=1.5.0=py36_0
- c-ares=1.19.0=h5eee18b_0
- ca-certificates=2023.05.30=h06a4308_0
- certifi=2021.5.30=py36h06a4308_0
- cffi=1.10.0=py36_0
- cftime=1.0.0b1=py36h035aef0_0
- chardet=3.0.4=py36_0
- cryptography=3.3.2=py36h3c74f83_0
- curl=7.26.0=1
- cycler=0.10.0=py36_0
- dbus=1.13.18=hb2f20db_0
- decorator=4.1.2=py36_0
- entrypoints=0.2.3=py36_0
- et_xmlfile=1.0.1=py36_0
- expat=2.4.9=h6a678d5_0
- fontconfig=2.13.1=h6c09931_0
- freetype=2.11.0=h70c0345_0
- future=0.18.2=py36_1
- glib=2.63.1=h5a9c865_0
- gmp=6.1.0=0
- gmpy2=2.0.8=py36h55090d7_1
- gst-plugins-base=1.14.0=hbbd80ab_1
- gstreamer=1.14.0=hb453b48_1
- h5py=2.10.0=py36hd6299e0_1
- hdf4=4.2.13=h3ca952b_2
- hdf5=1.10.6=hb1b8bf9_0
- html5lib=0.9999999=py36_0
- icu=58.2=he6710b0_3
- idna=2.6=py36_0
- intel-openmp=2022.0.1=h06a4308_3633
- ipykernel=4.6.1=py36_0
- ipython=6.1.0=py36_0
- ipython_genutils=0.2.0=py36_0
- ipywidgets=7.1.0=py36_0
- jdcal=1.3=py36_0
- jedi=0.10.2=py36_2
- jinja2=2.9.6=py36_0
- jpeg=9b=0
- jsonschema=2.6.0=py36_0
- jupyter_client=5.1.0=py36_0
- jupyter_core=4.3.0=py36_0
- keyring=9.3.1=py36_0
- kiwisolver=1.3.1=py36h2531618_0
- krb5=1.19.4=h568e23c_0
- lcms2=2.12=h3be6417_0
- ld_impl_linux-64=2.38=h1181459_1
- libcurl=7.82.0=h0b77cf5_0
- libedit=3.1.20221030=h5eee18b_0
- libev=4.33=h7f8727e_1
- libffi=3.2.1=1
- libgcc=7.2.0=h69d50b8_2
- libgcc-ng=11.2.0=h1234567_1
- libgfortran-ng=7.5.0=ha8ba4b0_17
- libgfortran4=7.5.0=ha8ba4b0_17
- libgomp=11.2.0=h1234567_1
- libnetcdf=4.6.1=h2053bdc_4
- libnghttp2=1.46.0=hce63b2e_0
- libpng=1.6.37=hbc83047_0
- libsodium=1.0.10=0
- libssh2=1.10.0=h37d81fd_2
- libstdcxx-ng=11.2.0=h1234567_1
- libtiff=4.2.0=h85742a9_0
- libuuid=1.0.3=0
- libwebp-base=1.2.4=h5eee18b_1
- libxcb=1.15=h7f8727e_0
- libxml2=2.9.12=h03d6c58_0
- lz4-c=1.9.4=h6a678d5_0
- markupsafe=1.0=py36_0
- matplotlib=3.3.4=py36h06a4308_0
- matplotlib-base=3.3.4=py36h62a2d02_0
- mistune=0.7.4=py36_0
- mkl=2019.4=243
- mkl-service=2.3.0=py36he8ac12f_0
- mkl_fft=1.3.0=py36h54f3939_0
- mkl_random=1.1.0=py36hd6b4f25_0
- mpc=1.0.3=0
- mpfr=3.1.5=0
- mpmath=0.19=py36_1
- nbconvert=5.2.1=py36_0
- nbformat=4.4.0=py36_0
- ncurses=6.4=h6a678d5_0
- netcdf4=1.5.7=py36h0a24e14_0
- nose=1.3.7=py36_1
- notebook=5.0.0=py36_0
- numexpr=2.7.3=py36hb2eb853_0
- numpy=1.16.6=py36hbc911f0_0
- numpy-base=1.16.6=py36hde5b4d6_0
- olefile=0.44=py36_0
- openjpeg=2.4.0=h3ad879b_0
- openpyxl=2.6.1=py36_1
- openssl=1.1.1u=h7f8727e_0
- pandas=1.1.5=py36ha9443f7_0
- pandocfilters=1.4.2=py36_0
- path.py=10.3.1=py36_0
- pcre=8.45=h295c915_0
- pexpect=4.2.1=py36_0
- pickleshare=0.7.4=py36_0
- pillow=8.3.1=py36h2c7a002_0
- pip=21.2.2=py36h06a4308_0
- prompt_toolkit=1.0.15=py36_0
- ptyprocess=0.5.2=py36_0
- py=1.8.0=py36_0
- pycparser=2.18=py36_0
- pygments=2.2.0=py36_0
- pyopenssl=17.0.0=py36_0
- pyparsing=2.2.0=py36_0
- pypdf2=1.26.0=py_4
- pyqt=5.6.0=py36_2
- pyshp=1.2.12=py36_0
- pysocks=1.6.6=py36_0
- python=3.6.10=hcf32534_1
- python-dateutil=2.8.0=py36_0
- pytz=2018.9=py36_0
- pyzmq=16.0.2=py36_0
- qt=5.6.3=h8bf5577_3
- readline=8.2=h5eee18b_0
- requests=2.23.0=py36_0
- scipy=1.5.2=py36h0b6359f_0
- setuptools=58.0.4=py36h06a4308_0
- simplegeneric=0.8.1=py36_1
- sip=4.18=py36_0
- six=1.15.0=py36h06a4308_0
- sqlite=3.38.2=hc218d9a_0
- sympy=1.8=py36h06a4308_0
- terminado=0.6=py36_0
- testpath=0.3.1=py36_0
- tk=8.6.11=h1ccaba5_0
- tornado=4.5.2=py36_0
- traitlets=4.3.2=py36_0
- urllib3=1.21.1=py36_0
- wcwidth=0.1.7=py36_0
- wheel=0.34.2=py36_0
- widgetsnbextension=3.0.2=py36_0
- xlrd=1.2.0=py36_0
- xlwt=1.3.0=py36_0
- xz=5.4.2=h5eee18b_0
- zeromq=4.1.5=0
- zlib=1.2.11=0
- zstd=1.4.9=haebb681_0
prefix: /oakdata/anaconda3/envs/arcgispro-py3
Good luck, have fun!