How do I run python on my Vagrant vm instance that is CoreOS?

血红的双手。 提交于 2019-12-02 10:15:35

You can also install python on CoreOS using the below script, let's call it install_python.sh:

#!/bin/bash -e

PYPY_VERSION=5.10.1

wget -O - https://bitbucket.org/pypy/pypy/downloads/pypy3-v$PYPY_VERSION-linux64.tar.bz2 |tar -xjf -
mv -n pypy3-v$PYPY_VERSION-linux64 pypy

## library fixup
mkdir -p pypy/lib
if [[ -f /lib64/libncurses.so.5.9 ]]; then
        libncurses_version=5.9
else
        libncurses_version=6
fi

ln -snf /lib64/libncurses.so.$libncurses_version $HOME/pypy/lib/libtinfo.so.5

mkdir -p $HOME/bin

cat > $HOME/bin/python <<EOF
#!/bin/bash
LD_LIBRARY_PATH=$HOME/pypy/lib:$LD_LIBRARY_PATH exec $HOME/pypy/bin/pypy3 "\$@"
EOF

chmod +x $HOME/bin/python
$HOME/bin/python --version

You can add it as a provision script to your Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.provision "shell", path: "install_python.sh"
end

install python for core user or root user and use python interpreter using /home/core/bin/python for example:

$ /home/core/bin/python --version
Python 3.5.3 (3f6eaa010fce, Jan 11 2018, 04:44:35)
[PyPy 5.10.1 with GCC 6.2.0 20160901]

$ /home/core/bin/python          
Python 3.5.3 (3f6eaa010fce, Jan 11 2018, 04:44:35)
[PyPy 5.10.1 with GCC 6.2.0 20160901] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> 

Applications and dependencies such as python run in containers on CoreOS. There are many pre-built python containers, such as: https://quay.io/repository/freshbooks/python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!