如何在 CoreOS 的 Vagrant vm 实例上运行 python? [英] How do I run python on my Vagrant vm instance that is CoreOS?

查看:35
本文介绍了如何在 CoreOS 的 Vagrant vm 实例上运行 python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 CoreOS 的 Vagrant vm 实例上运行 python?我想访问 python 解释器.谢谢!

How do I run python on my Vagrant vm instance that is CoreOS? I would like to access the python interpreter. Thanks!

推荐答案

您也可以使用以下脚本在 CoreOS 上安装 python,我们称之为 install_python.sh:

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

您可以将其作为配置脚本添加到您的 Vagrantfile:

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

core 用户或 root 用户安装 python 并使用 python 解释器使用 /home/core/bin/python 例如:

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.
>>>> 

这篇关于如何在 CoreOS 的 Vagrant vm 实例上运行 python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆