Pycharm import RuntimeWarning after updating to 2016.2

14,546

Solution 1

This is a known issue introduced with the 2016.2 release. Progress can be followed on the JetBrains website here. According to this page it is due to be fixed in the 2017.1 release. 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.

Solution 2

The latest recommendation (Dec. 19, 2016) is to put this line at the top of your unit test script:

from __future__ import absolute_import

Solution 3

On OS X I've fixed this by replacing

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

Solution 4

On Ubuntu 16.04 Bobby's solution also works:

Just replace your local utrunner.py file at

/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

Share:
14,546
allenlin1992
Author by

allenlin1992

Software developer (Python/SQL/some JavaScript) interested in finance and cryptocurrencies.

Updated on June 13, 2022

Comments

  • allenlin1992
    allenlin1992 about 2 years

    After updating to new version 2016.2, I am getting

    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. This issue only came up after updating to 2016.2. Besides the warnings, the remaining code works fine.

    Edit: This is a known issue - https://youtrack.jetbrains.com/issue/PY-20171. They are suggesting to replace utrunner.py in PyCharm installation folder.

  • Jim Wright
    Jim Wright almost 8 years
    Replaced the old file (/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner‌​.py) with the file for download from youtrack.jetbrains.com (download link). Works perfectly for me.
  • Guy
    Guy almost 8 years
    There was a recent update the called 2016.2.2, which did not fix the issue yet...
  • Ben Schmidt
    Ben Schmidt almost 8 years
    This is still not fixed in pycharm-2016.2.3
  • Vadim Gremyachev
    Vadim Gremyachev over 7 years
    This doesn't seem to be fixed in 2016.3, the same warning occurs.
  • serup
    serup over 7 years
    I found mine installed at a different place, however it worked after replacing it with above version -- why did they not rollback? will doing this not make python unstable??
  • nevets1219
    nevets1219 over 7 years
    Doesn't appear to be fixed in 2016.3.1
  • steinar
    steinar over 7 years
    That fixes the problem for me, but I think it's not an official recommendation, as the user mentioning this doesn't seem to be a JetBrains dev. Since this warning turns up even if only doing absolute imports, wouldn't adding that line be an unnecessary piece of code which would need to be removed after their next release?
  • Brent Washburne
    Brent Washburne over 7 years
    It will probably need to be removed at some point in the future, yes. For more information, see stackoverflow.com/q/7075082/584846
  • steinar
    steinar over 7 years
    Yeah, my point was that it's really unnecessary in this case, since this particular __future__ import is only there for fixing a bug in PyCharm. The source code needs no fix, at least in my case. So it seems that following the advice in the accepted answer would be better, since then the source code doesn't need to be touched at all.
  • Michael
    Michael over 7 years
    Not fixed in 2016.3.2
  • user7610
    user7610 over 7 years
    I am in favor of from __future__ import absolute_import. If your Python 2.7 code can take it, I prefer to use all the future imports. It would simplify eventual move to Python 3.6.
  • Matthew Moisen
    Matthew Moisen over 7 years
    This is the only solution that worked for me. Downloading the other utrunner.py and replacing the original did not appear to work. Perhaps Pycharm was caching it; I didn't try restarting my machine.
  • MikeyE
    MikeyE over 7 years
    I just downloaded and implemented the workaround as per @Bobby 's instructions. Worked for me on Linux Debian Jessie running PyCharm 2016.3.2. NOTE: at the JetBrains url it states the bug is "obsolete" in PyCharm 2017.1.
  • RustyShackleford
    RustyShackleford about 7 years
    How does this bug get released