如何在你的Android手机上配置 Python 环境?( 二 )


git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k修改.zshrc文件,将ZSH_THEME="robbyrussell"改为ZSH_THEME="powerlevel10k/powerlevel10k" 。

  • 配置
重新打开Termux,输入p10k configure进入powerlevel10k的配置界面 。第一次会自动下载默认字体,安装后会自动退出,重新打开Termux即可 。
可以根据配置向导的提示,定制适合自己风格的终端界面 。
如何在你的Android手机上配置 Python 环境?

文章插图
 
3. 启用vi模式(可选)Termux命令行中修改已经输入的命令比较麻烦 。通过开启vi模式,用户可以像在vi编辑器里一样进行操作 。对于vi用户来说,进入这种模式后,编辑和修改命令就显得十分得心应手了 。
使用nano、neovim等终端编辑器修改.zshrc文件来进行配置,在plugins部分添加vi-mode项,开启vi模式 。在命令行状态下,按Esc键,即可进入vi模式的普通模式 。
如何在你的Android手机上配置 Python 环境?

文章插图
 
不过在默认的vi模式存在按键bug,需要在.zshrc文件最后添加如下配置:
# Better searching in command modebindkey -M vicmd '?' history-incremental-search-backwardbindkey -M vicmd '/' history-incremental-search-forward# Beginning search with arrow keysbindkey "33[1~" beginning-of-linebindkey "33[4~" end-of-linebindkey '^[[3~' delete-charbindkey "^[OA" up-line-or-beginning-searchbindkey "^[OB" down-line-or-beginning-searchbindkey -M vicmd "k" up-line-or-beginning-searchbindkey -M vicmd "j" down-line-or-beginning-search三、Python包安装与配置1. 安装环境配置# 配置pypi源pip install pip -Upip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple# 依赖项pip install wheelpip install setuptools --upgrade2 Python包安装
  • 安装numpy和scipy
# 添加第三方仓库curl -LO https://its-pointless.github.io/setup-pointless-repo.shbash setup-pointless-repo.sh# 从仓库安装numpy scipypkg install -y numpy scipy
  • 安装lxml
# 安装lxml的依赖项pkg install -y libxml2 libxslt# 安装lxmlpip install lxml
  • 安装pillow
# 安装pillow的依赖项pkg install -y libjpeg-turbo libtiff pkg install -y littlecms tk libwebp libsodium# 安装pillowpip install pillow
  • 安装matplotlib
# 安装matplotlib的依赖项pkg install -y freetype libpngpip install kiwisolver cycler pip install pyparsing python-dateutil# 安装matplotlibpip install matplotlib
  • 安装pandas
# 安装pandas的依赖项pip install -y pytz cython# 安装pandasexport CFLAGS="-Wno-deprecated-declarations -Wno-unreachable-code"pip install pandas
  • 安装jupyter
# 安装jupyter依赖项pkg install -y libzmq libcrypt pkg-config# 安装jupyter pip install jupyter待安装完成,输入jupyter notebook启动,将地址复制到浏览器中即可打开Jupyter 。
如何在你的Android手机上配置 Python 环境?

文章插图
 
四、IPython和NeoVim配置对于希望在终端下进行使用的同学,推荐IPython+NeoVim组合 。
1. IPython配置
  • 安装IPython
【如何在你的Android手机上配置 Python 环境?】# 安装yapfpip install yapf# 安装Pygmentspip install pygments# 安装ipythonpip install ipython
  • 创建配置文件
使用ipython profile create命令在
~/.ipython/profile_default/目录下的创建ipython_config.py配置文件 。
  • 修改配置文件
使用neovim、nano等终端编辑器修改
~/.ipython/profile_default/目录下的ipython_config.py文件,添加如下配置:
# 配置终端颜色c.InteractiveShell.colors = 'Linux'c.TerminalInteractiveShell.autoformatter = 'yapf' # 配置高亮方案,可通过pygmentize -L styles浏览所有可选配置c.TerminalInteractiveShell.highlight_style = 'monokai' # 配置魔术命令%editor使用的编辑器c.TerminalInteractiveShell.editor = 'nvim'2. NeoVim配置在配置NeoVim前,需要安装pynvim插件,以扩展NeoVim对Python的支持 。
pip install pynvim
  • 创建init.vim文件进行基本配置
在命令行下,通过nvim命令进入NeoVim编辑器,输入:e $MYVIMRC编辑NeoVim配置文件,使用:w进行保存,基本设置如下:
" 一般设置set nocompatible "关闭与vi的兼容模式set number "显示行号set nowrap"不自动折行set showmatch"显示匹配的括号set scrolloff=3"距离顶部和底部3行"set encoding=utf-8"编码set fenc=utf-8"编码set fileencodings=utf-8set hlsearch"搜索高亮syntax on"语法高亮set tabstop=4"tab宽度set shiftwidth=4set smarttabset backspace=indent,eol,startset expandtab"tab替换为空格键set fileformat=unix"保存文件格式set splitbelowset cmdheight=2set completeopt=longest,menuset splitrightset foldmethod=indentset foldlevel=99" 设置空格为leader键let mapleader=" "


推荐阅读