Why did I get SyntaxError: invalid syntax when importing GoogleStockDataExtract from google_screener_data_extract

Why did I get SyntaxError: invalid syntax when importing GoogleStockDataExtract from google_screener_data_extract

我想知道为什么我不能 import GoogleStockDataExtract from google_screener_data_extract。感谢任何帮助或建议。以下是步骤。

  1. 在 conda 中进行安装:
pip install google_screener_data_extract
  1. 运行 Spyder 中的代码:
from google_screener_data_extract import GoogleStockDataExtract
  1. 收到错误信息:
from google_screener_data_extract import GoogleStockDataExtract
Traceback (most recent call last):

  File "C:\Users\voyma\Anaconda3\envs\Python_ST\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-27-aff6e099a353>", line 1, in <module>
    from google_screener_data_extract import GoogleStockDataExtract

  File "C:\Users\voyma\Anaconda3\envs\Python_ST\lib\site-packages\google_screener_data_extract\__init__.py", line 1, in <module>
    from .google_screener_data_extract import GoogleStockDataExtract

  File "C:\Users\voyma\Anaconda3\envs\Python_ST\lib\site-packages\google_screener_data_extract\google_screener_data_extract.py", line 158
    print hh.result_google_ext_df.head()
           ^
SyntaxError: invalid syntax

您在使用 Python 3 吗?你可以通过python --version

的输出判断你是不是

看起来 google_screener_data_extract 声称与 Python 3 兼容,但 this line 无效 Python 3 代码:

print hh.result_google_ext_df.head()

应该是:

print(hh.result_google_ext_df.head())

这个项目已经 3 年没有更新了,所以你最好的选择可能是分叉它,进行更改并使用你的分叉。