[英]Pycharm import RuntimeWarning after updating to 2016.2
After updating to new version 2016.2, I am getting 更新到新版本2016.2后,我收到了
RuntimeWarning: Parent module 'tests' not found while handling absolute import
import unittest
RuntimeWarning: Parent module 'tests' not found while handling absolute import
import datetime as dt
'tests' is a package inside my main app package, and I receive these warnings when I try to execute unit tests inside this folder. 'tests'是我的主应用程序包中的一个包,当我尝试在此文件夹中执行单元测试时,我收到这些警告。 This issue only came up after updating to 2016.2.
此问题仅在更新至2016.2后出现。 Besides the warnings, the remaining code works fine.
除了警告,剩下的代码工作正常。
Edit: This is a known issue - https://youtrack.jetbrains.com/issue/PY-20171 . 编辑:这是一个已知问题 - https://youtrack.jetbrains.com/issue/PY-20171 。 They are suggesting to replace utrunner.py in PyCharm installation folder.
他们建议在PyCharm安装文件夹中替换utrunner.py。
This is a known issue introduced with the 2016.2 release. 这是2016.2版本中引入的已知问题。 Progress can be followed on the JetBrains website here .
JetBrains网站可以在此处取得进展。 According to this page it is due to be fixed in the 2017.1 release.
根据此页面,它将在2017.1版本中修复。 You can follow the utrunner.py workaround that others have mentioned in the meantime - a copy of this file is attached to the linked ticket.
您可以按照其他人在此期间提到的utrunner.py解决方法 - 此文件的副本附加到链接的故障单。
最新推荐(2016年12月19日)是将此行放在单元测试脚本的顶部:
from __future__ import absolute_import
On OS X I've fixed this by replacing 在OS X上我通过替换修复了这个问题
Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py
with an older version that can be found at http://code.metager.de/source/xref/jetbrains/intellij/community/python/helpers/pycharm/utrunner.py 可以在http://code.metager.de/source/xref/jetbrains/intellij/community/python/helpers/pycharm/utrunner.py找到旧版本
On Ubuntu 16.04 Bobby's solution also works: 在Ubuntu 16.04上, Bobby的解决方案也有效:
Just replace your local utrunner.py
file at 只需替换你当地的
utrunner.py
文件
/usr/local/pycharm-edu-3.0/helpers/pycharm/utrunner.py
by the one from the Jetbrains website: http://code.metager.de/source/xref/jetbrains/intellij/community/python/helpers/pycharm/utrunner.py 来自Jetbrains网站的一个: http : //code.metager.de/source/xref/jetbrains/intellij/community/python/helpers/pycharm/utrunner.py
On Windows 10 Bobby's solution also works: 在Windows 10上,Bobby的解决方案也有效:
Just replace your local utrunner.py file at 只需替换你当地的utrunner.py文件
C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pycharm
with the one from the Jetbrains website: http://code.metager.de/source/xref/jetbrains/intellij/community/python/helpers/pycharm/utrunner.py 与Jetbrains网站上的一个: http : //code.metager.de/source/xref/jetbrains/intellij/community/python/helpers/pycharm/utrunner.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.