1

i created a python sript but when ever i import the scripts from their folder i get ModuleNotFoundError: No module named 'reconstructors' but the scripts are there

funtions/reconstructors.py
funtions/handlers.py

import reconstructors as resx
import handlers as hand

then when i call the script i use them in sentenceform.py to anotheer script, I get

ModuleNotFoundError: No module named 'reconstructors'

then if remove reconstructors, I get

ModuleNotFoundError: No module named 'handlers'

this is sentenceform.py

import reconstructors as resx
import handlers as hand

def storeNewWrd(datname, val):
    import json_function as js
    data= js.loadJsonData(datname)
    find = hand.existInJsonData(dataname, val, 'words')
    if  find == False:
        data['words'].append({val : val})
        js.EditJsonData(data, datname)
        return True
    else:
        return False

def like(arg, dic):
    word1 = arg.split()
    word2 = dic.split()
    sol =0

    for wd2 in word2:
        for wd1 in word1:
            if wd1 == wd2:
                sol += 1 
    if sol/len(word2) * 100 > 97.0:
        return True
    else:
        return False        

# def ReConstructSentence(sentence):



def addWord(sentence):
    import json_function as js
    Wrds = sentence.split()
    data = js.loadJsonData('data')
    for i in range(len(Wrds)):
        Wrds[i] = resx.removeNonWordCharacters(Wrds[i])
        for datas in data['words']:
            if like(datas, Wrds[i]) == True:
                if hand.existInJsonData('data', Wrds[i], 'words'):
                    return False
            else:
                print(sentenceWrds[i])
                # storeNewWrd(datname, val)
                # return True`enter code here`
enamoria
  • 896
  • 2
  • 11
  • 29
sirdavis99
  • 41
  • 6

1 Answers1

1

the trick is to use a path definition to specify folder for ease access

import sys
# the mock-0.3.1 dir contains testcase.py, testutils.py & mock.py
sys.path.append('/home/davis/Desktop/lisa/SentForm/functions')
import reconstructors as resx
import json_function as js
import handlers as 
sirdavis99
  • 41
  • 6