我尝试将tensorflow 2.0合并到anaconda中以在jupyter笔记本中使用。然而,出现了许多问题,从未检测到模块tensorflow到卸载并重新安装anaconda。接下来是成功的 pip 安装,然后是不同版本的 Python,将其从 3.9.1 更新到 3.12.7。现在 numpy 包不再工作并且变得无法使用。
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.3 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
现在你可以做:
pip install "numpy<2.0"
或
pip install numpy=1.26.4