Couldn't find program: 'pypy' on Google Colab. Solution or alternatives?

三世轮回 提交于 2021-02-10 05:42:06

问题


I'm getting this error in a google colab notebook. Do I need to install something or it's just not possible to use pypy inside colab? I've tried this simple script:

%%pypy
print("hello")

# Couldn't find program: 'pypy'

If I run %lsmagic the output is the following, in which pypy is present.

Available line magics:
%alias  %alias_magic  %autocall  %automagic  %autosave  %bookmark  %cat  %cd  %clear  %colors  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %man  %matplotlib  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %pip  %popd  %pprint  %precision  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %save  %sc  %set_env  %shell  %store  %sx  %system  %tb  %tensorflow_version  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode

Available cell magics:
%%!  %%HTML  %%SVG  %%bash  %%bigquery  %%capture  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%shell  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile

Automagic is ON, % prefix IS NOT needed for line magics.

Eventually are there some alternatives? I've already tried numba but due to the fact that mostly need it to preprocess data I usually need obejcts that seems to make numba unable to compile in a nopython mode. So I'm looking for something more flexible like pypy.


回答1:


You can use pypy in Colab once you install it on the Colab VM:

!apt-get install pypy
%%pypy
import sys
print(sys.executable)
# /usr/bin/pypy


来源:https://stackoverflow.com/questions/61198912/couldnt-find-program-pypy-on-google-colab-solution-or-alternatives

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