How to convert existing directory into a python package in Pycharm4
The reason you can not import from crawler
is that crawler
is not a python package. Its just a directory (as you already know)
It doesn't seem worth your time to troubleshoot what may be a bug in the IDE, when you all need to do is create the empty __init__.py
yourself.
Having the __init__.py
inside a child directory is not enough. Each directory needs its own __init__.py
Manually adding an empty file called __init__.py
to that top level folder crawler
folder will turn this into a python package.
Once done, refresh your Pycharm project.
wolfgang
Updated on July 17, 2022Comments
-
wolfgang almost 2 years
I have an option to
create a python package
in PyCharm in the project directoryand when i use
import newpackage
PyCharm Recognizes this.I'm using PyCharm4, and when i try to "refractor" a directory to a package, i can't because the button is DISABLED. i can only see the convert to python module option
I've Tried adding the directory to "paths"
And Still No Success in getting PyCharm to recognize
import
statementsI'm using PyCharm4
My Question again, How can i convert a directory into a python package so that PyCharm will not show an error during
import
statementsEdit I do have an
__init__.py
file inside the child directory. still no luckEdit2 @joran
I've added the error screen like you requested, you can see the red underline marking the error