Python如何获取有关SyntaxError的更多信息?

2024-06-07 15:17:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在Ubuntu映像容器上运行Python代码,其中包含所有必需的库

Bootstrap: docker
From: ubuntu

%post
apt-get -y update
apt-get -y install python python3-pip curl
pip3 install scikit-learn cython numpy pydot keras torch torchvision
pip3 install matplotlib pandas plotly nltk seaborn scrapy gensim tensorflow xgboost textblob
pip3 install gym kaggle-environments stable-baselines3

我正在命令行中运行代码。当我运行简单的Hello World代码时,它就工作了

cat hello.py | singularity exec connectx.simg  /usr/bin/python

Hello World!

但当我尝试运行另一个需要各种库的脚本时,我得到了SyntaxError:

cat training3.py | singularity exec connectx.simg  /usr/bin/python
  File "<stdin>", line 26
    def __init__(self, observation_space: gym.spaces.Box, features_dim: int = 512):
                                        ^
SyntaxError: invalid syntax

我不清楚是什么导致了Syntaxer错误。如何获取有关此错误的更多信息


Tags: install代码pyhelloworldgetusrpip3

热门问题