我想安装 Python 3.10.5(或至少 Python >= 3.7)。我按照以下说明操作:
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
# Step 2. Install missing headers for all the Python modules to be built
sudo zypper install readline-devel sqlite3-devel libbz2-devel
# Step 3. Install the desired Python version
pyenv install 3.10.5
Run Code Online (Sandbox Code Playgroud)
直到我到达pyenv install 3.10.5:
bscuser@localhost:~> pyenv …Run Code Online (Sandbox Code Playgroud) 这:
import tensorflow as tf
from transformers import BertTokenizer, TFBertForSequenceClassification
model = TFBertForSequenceClassification.from_pretrained("bert-base-uncased")
Run Code Online (Sandbox Code Playgroud)
输出以下错误:
ImportError:
TFBertForSequenceClassification requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the
installation page: https://www.tensorflow.org/install and follow the ones that match your environment.
Run Code Online (Sandbox Code Playgroud)
然而,事实并非如此,我没有导入 TensorFlow 库。
> print(tf.__version__)
'2.7.0'
Run Code Online (Sandbox Code Playgroud)