How to import python file located in same subdirectory in a pycharm project

前端 未结 8 1619
盖世英雄少女心
盖世英雄少女心 2020-12-13 08:48

I have an input error in pycharm when debugging and running.

My project structure is rooted properly, etc./HW3/. so that HW3 is the root di

8条回答
  •  误落风尘
    2020-12-13 09:19

    Note: May be a bit unrelated.

    I was facing the same issue but I was unable to import a module in the same directory (rather than subdirectory as asked by OP) when running a jupyter notebook (here the directory didn't have __init__.py). Strangely, I had setup python path and interpreter location and everything. None of the other answers helped but changing the directory in python did.

    import os
    os.chdir(/path/to/your/directory/)
    

    I'm using PyCharm 2017.3 on Ubuntu 16.04

提交回复
热议问题