How to convert existing directory to python package in Pycharm4

I have an option create a python package

in PyCharm in my project directory

and when I use import newpackage

PyCharm it recognizes this.

I am using PyCharm4 and when I try to "refract" a directory in a package I cannot because the button is disabled. i can only see conversion option to python module

enter image description here



I tried adding a directory to "paths"

enter image description here

And still no success in getting PyCharm to recognize operators import

I am using PyCharm4

My question is again, How to convert a directory to a python package so that PyCharm does not display an error during import

statement

Edit I have a file __init__.py

inside a child directory. no luck yet

Edit2 @joran

I added an error screen as you asked, you can see a red underline indicating the error

enter image description here

+3


source to share


1 answer


The reason you can't import from crawler

is because crawler

it is not a python package. Its just a directory (as you already know)

It is not worth wasting time troubleshooting, which can be a mistake in the IDE, when all you need to do is create an empty one __init__.py

yourself.

Insufficient presence __init__.py

inside child directory. Each directory needs its own__init__.py



Manually adding an empty file named __init__.py

to the top level folder crawler

will turn this into a python package.

After that, update your Pycharm project.

+5


source







All Articles