i know that the problem I'm asking for have thousand of questions and answers, but i need an explanation for my spcific problem because is my first time using code written by others and I'm really confused about imports. So: I'm usin Pycharm and I pulled all the code (organized in directories) directly from a gitLab repo.
this is the structure :
C:\users\marco\PycharmProjects\Avv
└──ads-ai
└──src
└──dataElab
└──dataprep.py
└──datamod.py
├──doc2vec
├──logger
└──log_setup.py
├──res
├──mod1.py
├──mod2.py
├──mod3.py
└──rest
└──api.py
my starting script is api.py , and I need to import mod1.py in there-
but start writing
import mod1
gives me an error.
the problem also is that on mod1, there are others import:
from logger import log_setup
from dataElab import dataprep, datamod
all imports give me the error 'NoModuleFound'. I tried: -add the path with sys.path.append - relative paths (from .. import mod1) but gives me ValueError: attempted realtive import beyond top-level package -absolute path
but nothing, i have always the "no module" error, for mod1 or for log_setup.
I want to use the script of Pycharm, not the Python Console. If I check with os.getwd() --> C:\users\marco\PycharmProjects\Avv\ads-ai\src\rest (should be correct).
and with sys.path --->
['C:\Users\marco.onnis\PycharmProjects\Avvocatura2020\ads-ai\src\restAPI', 'C:\Users\marco.onnis\PycharmProjects\Avvocatura2020', 'C:\Users\marco.onnis\AppData\Local\Continuum\anaconda3\envs\Avvocatura2020\python36.zip', 'C:\Users\marco.onnis\AppData\Local\Continuum\anaconda3\envs\Avvocatura2020\DLLs', 'C:\Users\marco.onnis\AppData\Local\Continuum\anaconda3\envs\Avvocatura2020\lib', 'C:\Users\marco.onnis\AppData\Local\Continuum\anaconda3\envs\Avvocatura2020', 'C:\Users\marco.onnis\AppData\Local\Continuum\anaconda3\envs\Avvocatura2020\lib\site-packages', 'C:\Users\marco.onnis\AppData\Local\Continuum\anaconda3\envs\Avvocatura2020\lib\site-packages\xlsxwriter-1.2.8-py3.6.egg']
I'm so sorry if I'm asking again this type of questions, but I've problem understanding the concept of name , main and all that stuf, and I don't know what to do in my specific case ( I hope then to understand in general the topic)
thanks a lot!