deepchem / deepchem/deepchem

Import error

Open
#4,378 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Hi, I just found an import error when I tried to run deepchem on Pycharm. Here is the code

!pip install --pre deepchem[tensorflow]
!pip install tf_keras
import os
os.environ['TF_USE_LEGACY_KERAS'] = 'True'
import deepchem as dc
dc.__version__

tasks, datasets, transformers = dc.molnet.load_delaney(featurizer='GraphConv')
train_dataset, valid_dataset, test_dataset = datasets

model = dc.models.GraphConvModel(n_tasks=1, mode='regression', dropout=0.2,batch_normalize=False)

model.fit(train_dataset, nb_epoch=100)

After this step, there is an import error that says:
ImportError: `keras.optimizers.legacy` is not supported in Keras 3. When using `tf.keras`, to continue using a `tf.keras.optimizers.legacy` optimizer, you can install the `tf_keras` package (Keras 2) and set the environment variable `TF_USE_LEGACY_KERAS=True` to configure TensorFlow to use `tf_keras` when accessing `tf.keras`.

I hope someone can help me with this issue.

![Image](https://github.com/user-attachments/assets/fb25954e-824b-4eba-9876-65727acaefd1)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.