Import Vertex AI SDK raises AttributeError: module 'bigframes' has no attribute 'dataframe'

515 Views Asked by At

I got an error when I tried to import vertexai recently in Colab. This is blocking me using Gemini etc.

I found that Vertex SDK has a fix for that. The root cause is BigFrames has a recent major release. Before Vertex SDK cut a release, the temporary workaround is force reinstall bigframes<1.0.0.

https://github.com/googleapis/python-aiplatform/commit/cdb8e6afc3791ca5b3c86e516dde2c3f111401f0#comments

2

There are 2 best solutions below

0
Poala Astrid On

Since the temporary workaround suggested is to force reinstall bigframes with a version less than 1.0.0 until the Vertex SDK cuts a release with a fix, you can reinstall bigframes with a compatible version:

!pip install --force-reinstall bigframes<1.0.0

This command will reinstall bigframes with a version lower than 1.0.0, which should resolve the compatibility issue until a new release of the Vertex SDK is available with a permanent fix. After reinstalling bigframes, you should be able to import vertexai without encountering errors.

Also, since you're encountering an AttributeError stating that the module 'bigframes' has no attribute 'dataframe' after importing the Vertex AI SDK, it suggests that there might be an issue with the way the SDK interacts with the 'bigframes' module. This could be due to changes in the bigframes module or in the SDK itself.

One possible workaround is to explicitly import the necessary components from 'bigframes' before importing the Vertex AI SDK. Here's how you can do it:

import bigframes.dataframe

# Import the Vertex AI SDK
import vertexai

By explicitly importing bigframes.dataframe before importing the Vertex AI SDK, you ensure that the necessary components are available for the SDK to function properly. This might resolve the AttributeError you're encountering.

If the issue persists, it's possible that there's a deeper compatibility issue between the versions of 'bigframes' and the Vertex AI SDK you're using. In that case, you may need to wait for an updated release of the SDK that addresses the compatibility issue or reach out to the maintainers for further assistance.

0
fahaisouxun On

Simply pip install the latest version of bigframes before 1.0.0:

!pip install bigframes==0.26.0