Error in Google Colab: SystemError: This interpreter version: '3.7.10' doesn't match with version of the interpreter ViZDoom was compiled with: 3.7.11

Error in Google Colab: SystemError: This interpreter version: '3.7.10' doesn't match with version of the interpreter ViZDoom was compiled with: 3.7.11

我正在使用 Google Colab 将 运行 ViZDoom 与 TensorFlow(特别是 TF-Agents 库)结合使用。 大多数时候,当我用我的代码启动 Colab notebook 时,我会收到以下错误:

SystemError: This interpreter version: '3.7.10' doesn't match with version of the interpreter ViZDoom was compiled with: 3.7.11

当我尝试导入 vizdoom 时,在安装了所有依赖项和其他库后 (from vizdoom import *),就会发生这种情况。

我已经设法让 Colab notebook 正常工作,只需从头开始重新 运行ning 一下。不过,有时 运行 从头开始​​重新设置它是行不通的。这似乎有助于在所有安装之前使用 !python3 --version 添加对解释器版本的检查,但这不应该为安装设置 python 版本。

我也尝试过以两种不同的方式安装 ViZDoom,这两种方式都显示在下面的完整代码中。这两种安装方式都无法始终如一地工作。

为什么解释器版本会改变?有没有办法让它保持不变,这样我就不必在它随机发生不起作用时重新安装所有东西?

我运行宁的代码直到问题是(每个方框都是 Colab 笔记本的一部分):

from google.colab import drive
drive.mount('/content/drive')
# To check Python version:
# !python3 --version

%%bash
# Install deps from 
# https://github.com/mwydmuch/ViZDoom/blob/master/doc/Building.md#-linux
apt update
apt upgrade

apt install build-essential zlib1g-dev libsdl2-dev libjpeg-dev nasm tar libbz2-dev libgtk2.0-dev \
cmake git libfluidsynth-dev libgme-dev libopenal-dev timidity libwildmidi-dev unzip

# Boost libraries
apt install libboost-all-dev

# Lua binding dependencies
apt install liblua5.1-dev

apt update
apt upgrade
!pip install tf-agents
%%bash
apt update
apt upgrade
# Neither way of installing ViZDoom seem to work consistently. I am installing ViZDoom either way at a time, not both ways at the same time.
!pip install git+https://github.com/mwydmuch/ViZDoom
#!pip install vizdoom
### LINE THAT GOES WRONG ###
from vizdoom import *
### LINE THAT GOES WRONG ###

import numpy as np
import pandas as pd
import seaborn as sbrn

import tensorflow as tf
from tensorflow import keras

from tf_agents.agents.ppo import ppo_agent
from tf_agents.environments import py_environment
from tf_agents.environments import tf_py_environment
from tf_agents.specs import array_spec, BoundedArraySpec, ArraySpec
from tf_agents.networks.actor_distribution_rnn_network import ActorDistributionRnnNetwork
from tf_agents.networks.value_rnn_network import ValueRnnNetwork
from tf_agents.trajectories import time_step

import time
import random

我将安装库的方式更改为 Google Colab。从那以后,我再也没有遇到过 TF-Agents 和 ViZDoom 的问题。

我没有将多个单元以不同的方式进行每次安装,而是将所有这些单元收集到一个单元中,使用单一格式来安装库:

#%%bash

# Install deps from 
# https://github.com/mwydmuch/ViZDoom/blob/master/doc/Building.md#-linux
!sudo apt update
!sudo apt upgrade

!sudo apt install build-essential zlib1g-dev libsdl2-dev libjpeg-dev nasm tar libbz2-dev libgtk2.0-dev \
cmake git libfluidsynth-dev libgme-dev libopenal-dev timidity libwildmidi-dev unzip

# Boost libraries
!sudo apt install libboost-all-dev

# Lua binding dependencies
!sudo apt install liblua5.1-dev

#Install TF-Agents
!pip install tf-agents

#Install ViZDoom
!pip install git+https://github.com/mwydmuch/ViZDoom

!sudo apt update
!sudo apt upgrade

可能,按照单一方法进行这些安装允许版本在所有安装中兼容,这就是它起作用的原因。