1. 須要安裝python, 從 python.org上下載版本,我下的是python3.5,網上搜索到的是python2.7的交叉編譯過程php
和820的結合下。html
須要注意,先把820的環境設置好,就是$CC是交叉編譯的那個CC,另外加入到$PATH裏了。python
python依賴openssl,下載交叉編譯好,指定 /opt/agl/openssl爲 --prefix 安裝目錄。linux
編譯python以前,先用 make python Parser/pgen 編譯出來pgen. shell
./configure --prefix=/opt/agl/python3.5 --host=aarch64-agl-linux --build=x86_64-linux-gnu ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=noubuntu
須要把前面編譯出來的pgen拷貝到 /opt/agl/python3.5下。python2.7
編譯前,更改Makefile,把openssl的連接目錄 -L... 加入到 CONFIG_LDFLAGS裏工具
編譯時提示編譯錯誤,相似乎某個頭文件... 但ubuntu下時不報這樣的錯誤。測試
由於有的頭文件時從別的地方生成的,頭文件第一行時註釋: /* .... */網站
交叉編譯工具不能識別這樣的。 大概有三個文件時這樣的,挨個刪掉第一行註釋。
2. 編譯完須要拷貝到板子上,安裝一些python工具
安裝pip,用 get-pip.py,發現不行。下載pip-19...源碼,安裝時報錯。
用pip安裝軟件很困難,總是報錯誤:certificate verify failed 一類的。
搜索不少地方,好不容易纔找到解決方案,須要:
pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org <package>
緣由是:是Python 的輪子網站不信任咱們的證書。
另外一個地方提示: 這個錯誤的緣由是某網站再也不支持TLS1.0和TLS1.1版本,pip以前的版本是使用TLS1.0或TLS1.1因此解決方案是從新安裝pip。
但我這個pip是下載最新的pip源碼安裝的。
能夠增長一個pip.conf,參考https://www.jianshu.com/p/ac4df573b9d9。我在ubuntu下的/etc下增長這個文件,
[global] index-url = http://pypi.douban.com/simple #豆瓣源,能夠換成其餘的源 extra-index-url = https://pypi.tuna.tsinghua.edu.cn/simple trusted-host = pypi.douban.com #添加豆瓣源爲可信主機,要否則可能報錯 pypi.tuna.tsinghua #清華 timeout = 120
發現板子上原來有python,2.7.12版本。
ln -s /usr/lib64/python2.7 /usr/lib/python2.7
ubuntu下不存在這個問題。
但發現這個python版本不少內嵌的模塊沒有,因而決定本身編譯一個版本。
搜索網上資料,彷佛是2.7.13版本及其如下,作交叉編譯須要打補丁(參見http://www.cnblogs.com/pengdonglin137/p/6588253.html)。安裝2.7.16,我參考了別的網頁,沒有打補丁,後來相似的方法編譯安裝2.7.13,沒打補丁,彷佛也成功了。
2.7.16(ftp.python.org下載),
mkdir localbuild armbuild
cd localbuild
../configure --prefix=`pwd` && make -j4 && sudo make install
cd ../armbuild
../configure --prefix=/opt/agl/python2.7.13 --host=aarch64-agl-linux --build=x86_64-linux-gnu ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no
網上說python以來openssl,交叉編譯,在python的Makefile中加上 -Lopenssl-1.0.2r/build/lib,
另外,編譯以前須要註釋掉setup.py中的兩行:(參見 https://www.cnblogs.com/pengdonglin137/p/6596977.html)
15 if ext.name in sys.builtin_module_names: 16 self.extensions.remove(ext)
make HOSTPYTHON=../localbuild/Python HOSTPGEN=../localbuild/Parser/pgen
make -i install HOSTPYTHON=../localbuild/Python HOSTPGEN=../localbuild/Parser/pgen
若是直接install,容易出現這樣的錯誤
ImportError: /home/tangjian/source/Python-2.7.16/build/lib.linux2-aarch64-2.7/_struct.so: cannot open shared object file: No such file or directory
這個問題是因爲安裝時使用了python,但Makefile中指定了錯誤的庫,使用了arm平臺上的so,顯然這是不能在咱們的x86linux上運行的。
ImportError:/work/winshare/build.arm/build/lib.linux2-arm-2.7/_struct.so: cannot openshared object file: No such file or directory
make: *** [libinstall] Error 1
這個問題是因爲安裝時使用了python,但Makefile中指定了錯誤的庫,使用了arm平臺上的so,顯然這是不能在咱們的x86linux上運行的。
修改build.arm下的Makefile
在Makefile中查找PYTHONPATH,將build.pc目錄下的庫文件路徑添加到PYTHONPATH中,如:
PYTHON_FOR_BUILD=_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM)PYTHONPATH=../localbuild/build/lib.linux-x86_64-2.7:$(shelltest -f pybuilddir.txt && echo $(abs_builddir)/`catpybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) python2.7
注意,全部的PYTHONPATH中都須要修改。
按照前面說的或者參見https://m.2cto.com/kf/201511/448789.html,能夠解決這個問題。
參考https://tecadmin.net/install-sendmail-on-ubuntu/,最後測試發送郵件,發到公司的很快就收到了,可是發送到yeah.net的,收到郵件花了至少3分鐘。
python代碼,sender = 'tangjian@tangjian.dell' 改成 sender = 'tangjian@tangjian-dell',結果發送就失敗
/etc/hosts, 127.0.0.1 tangjian.dell tjnote
已經運行過了命令: hostname tangjian.dell