Install Python 3 on Cloudready/Chromium/Chrome OS without installing Linux containers/environments

后端 未结 2 1660
情话喂你
情话喂你 2020-12-22 00:58

Recently I installed Neverware\'s version of Chromium OS, called Cloudready, on VirtualBox 6.1, to develop Python apps for Chromebooks. This version of Chromium OS is 48.0.2

相关标签:
2条回答
  • 2020-12-22 01:48

    The answer that explains why Miniconda doesn't install was correct that /tmp is mounted as noexec (mounted with no executable permission). Unfortunately, their suggested approach to fix it (specify a different TMPDIR directory for installation) did not work for me. However, I eventually managed to find a different approach.

    So, reboot the Chromebook and enter Developer Mode. Open the Crosh (Chrome Developer Shell) and type in the command shell to access the hidden Bash shell (as I am using Chromium OS developer build, not Chrome OS, I do not need to enter a developer mode to access the Bash shell).

    Now, instead of specifying a different TMPDIR directory as suggested in the answer I've referenced earlier, remount tmp as exec (with executable permission):

    sudo mount /tmp -o remount,exec
    

    When prompted for a password, type in the password for user chronos. There are (apparently) several different default passwords for chronos, including facepunch, password, chrome, localhost, test0000, and a blank password (nothing). In my case it was chrome. If you are using an official Chromebook and have booted into Developer Mode, you should have set a password with chromeos-setdevpasswd when enabling Developer Mode (for more information click here).

    After that, download the Miniconda installation script for Linux from the Conda website (remember to download the 64-bit version though), change the working directory to the location of the downloaded Miniconda installation script file, run it, and change the install location to a location with write privileges (in my case /usr/local/conda3).

    cd ~/Downloads
    sudo bash ~/Downloads/Miniconda3-latest-Linux-x86_64.sh -p /usr/local/conda3
    

    When installation finishes, you must add your Conda installation to PATH:

    echo "PATH=/usr/local/conda3/bin:$PATH" >> ~/.bashrc
    

    Restart the Crosh and enter the Bash shell again. Verify that the directory of the installed Conda binaries is in PATH with echo $PATH and if /usr/local/conda3/bin is in PATH, verify that Python is installed with python3 --version.

    Now it is time to install other modules. The installation of Miniconda includes the package manager Conda which specifically installs Python packages (however, there are some other packages available in Conda, such as GCC). Using Conda, you can install Tkinter, PyInstaller, and many other Python packages:

    conda install -c anaconda tk
    conda install -c anaconda pyinstaller
    

    Installing PyInstaller works, but it appears that on Chromium OS, there is no such tool as objcopy, meaning that PyInstaller cannot compile any Python scripts, and, as explained in the PyInstaller requirements, ldd, objcopy, and objdump must be installed for PyInstaller to work on Linux installations. The workaround for this is to compile Python scripts with PyInstaller on another Linux computer and then run the compiled script on Chrome/Chromium OS.

    Also, on newer versions of Chromium OS, graphical Python applications (made with Tkinter, PyQt, etc.) don't run because they don't recognise the system DISPLAY environment variable. The problem is that the entire graphical display of Chrome/Chromium OS is controlled by the Google Chrome web browser program and the web browser runs with no DISPLAY variable, meaning that any GUI program started in the OS by the user (meaning that it would be started by the Chrome browser) would start with no DISPLAY variable.

    The workaround is to set the DISPLAY variable for the Chrome browser. To do this, you will need to login as root with the command sudo su, as Crosh does not allow editing the file you will need to edit, even with the sudo command. After logging in as root with sudo su, you will need to run the following commands:

    mount -o remount,rw /dev/root /
    echo "DISPLAY=:0" >> /etc/chrome_dev.conf
    

    Then reboot, and now you should be able to run graphical Python programs as well as console Python programs.

    0 讨论(0)
  • 2020-12-22 01:56

    There can be 2 possibilities:

    1). The python3.6 is already installed.

    WARNING: A requested package will not be merged because it is listed in
    package.provided:
    

    To check that try:

    which python3 or simply try running python3.

    2). uninstalling python2 so that the merge will not even be necessary can also help you out.

    0 讨论(0)
提交回复
热议问题