question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error importing ray in colab due to pyarrow

See original GitHub issue

System information

  • colab
  • pip install ray[rllib]
  • python 3.7

Describe the problem

Very simple, just pip install ray, then import ray:

!pip install tensorflow  # or tensorflow-gpu
!pip install ray[rllib]  # also recommended: ray[debug]
import ray

on Google colab and it fails with:

ImportError: Ray must be imported before pyarrow because Ray requires a specific version of pyarrow (which is packaged along with Ray).

Recreate

Take a look at this gist running on colab

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
pcmoritzcommented, Jun 25, 2019

Thanks for reporting this! This error happens because colab is preloading certain libraries (more on this below). To fix it, you can do the following:

!pip install tensorflow  # or tensorflow-gpu
!pip install ray[rllib]  # also recommended: ray[debug]
!pip uninstall -y pyarrow

and then click on Runtime/Restart runtime. After that, the Ray cell will work.

Now as to why colab’s preloading is problematic: Ray depends on a library called pyarrow for serialization and some other things. Because TensorFlow’s binary package is not compliant with the manylinux1 standard [1], we need to ship a custom version of pyarrow that is compatible with TensorFlow. Until TensorFlow is fixed, we don’t really have a choice here, so sorry for that.

[1] https://groups.google.com/a/tensorflow.org/d/msg/developers/TMqRaT-H2bI/J1Wiu8_XCQAJ

1reaction
richardliawcommented, Dec 27, 2019

Just a note - the way we get around this on our tutorial notebooks is by using this block of code before running anything:

print("Setting up colab environment")
!pip uninstall -y -q pyarrow
!pip install -q ray[debug]

# A hack to force the runtime to restart, needed to include the above dependencies.
print("Done installing! Restarting via forced crash (this is not an issue).")
import os
os._exit(0)
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "ImportError: PyArrow >= 0.8.0 must be installed; ...
The error message in this case is misleading, pyarrow wasn't installed. ... pip uninstall pyarrow -y $ pip install pyarrow.
Read more >
Issue might happen import PyArrow
Depending on your Linux OS, especially with Ubuntu, you might run into issue like, when you installed pyarrow by conda install. >>> import...
Read more >
RLlib Tutorial - Colaboratory
print('NOTE: Intentionally crashing session to use the newly installed library.\n') !pip uninstall -y pyarrow !pip install ray[debug]==0.7.5
Read more >
Installation — Modin 0.12.1+0.g34962ec.dirty documentation
Installing on Google Colab¶. Modin can be used with Google Colab via the pip command, by running the following code in a new...
Read more >
5 Amazing Google Colab Hacks You Should Try Today
The 'out of memory' error is now quite infamous in the data science community – Google Colab provides us with the workaround and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found