在python中尝试"导入epipy"或"从epipy import *"出错(使用pycharm IDE)



当我尝试导入 epipy 时,即使我将包安装到项目解释器(python 文件的解释器也设置为相同的环境),Python 也会抛出错误)

  • 尝试使用绝对导入;从 epipy 导入 *

  • 尝试导入特定功能,例如从 epipy 导入case_tree

  • 已尝试卸载并重新安装软件包

我的代码:

进口大熊猫作为PD

进口皮

我希望导入已安装的软件包没有错误,收到以下错误:

/Users/Noelle/Python/stats/bin/python /Users/Noelle/Python/stats/basic_analytics.py
Traceback (most recent call last):
  File "/Users/Noelle/Python/stats/basic_analytics.py", line 2, in <module>
    import epipy
  File "/Users/Noelle/Python/stats/lib/python3.6/site-packages/epipy/__init__.py", line 5, in <module>
    from .analyses import generation_analysis, reproduction_number, create_2x2
  File "/Users/Noelle/Python/stats/lib/python3.6/site-packages/epipy/analyses.py", line 88
    print 'Summary of reproduction numbers'
                                          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Summary of reproduction numbers')?

进程已完成,退出代码为 1

您是从 pip 还是直接从 github 安装的?根据这篇文章,pip 版本只兼容 python 2,对于 py3.x,你必须直接下载 github 版本

该错误是因为正在调用 print:

print'Summary of reproduction numbers'

而不是:

print('Summary of reproduction numbers')

Python 3 打印语法与 Python 2 不同

编辑:似乎这是因为您安装的 epipy 包适用于 python 2 而不是 python 3

最新更新