| Quote: |
| When I looked at the Python Console I got the message that is shown in the pic above. |
| Quote: |
| ImportError: No module named console_ |
| Quote: |
| print sys.path |
| Lilliepad wrote: |
| I feel like I am not getting anywere closer to solving it.
I just know it does not work and have no clue why at all. when i run it is say: bpy.ops.text.run_script() and that does not do anything. Maybe I messing stuff up more by trying to fix it with out knowing what I am really doing Atleast python seem to work and I have the latest version of both python and Blender |
| Code: |
|
import ... from ... |
| Code: |
| import imp
pathToDxfExport = 'path goes here, okay maybe one should rename the variable, do it at your desire' thefile, pathname, descriptionTriple = imp.find_module() #import functions thefile, pathname, description = imp.find_module('functions', [pathToDxfExport + '']) art = imp.load_module('functions', thefile, pathname, description) |
| Code: |
|
#from .export_dxf import exportDXF |
| Code: |
|
############################################# # Some helper functions due to import mess. # #-------------------------------------------# #* #IMPORT FILE #with m = module def importFile(fullPathToModule): # try: import os moduleDir, moduleFile = os.path.split(fullPathToModule) moduleName, moduleExt = os.path.splitext(moduleFile) savedCwd = os.getcwd() #we want to return to it later os.chdir(moduleDir) moduleObj = __import__(moduleName) moduleObj.__file__ = fullPathToModule globals() [moduleName] = moduleObj #so that it can be reached os.chdir(savedCwd) #return to initial path # except: # raise ImportError("something went wrong")# + self.__LINE__) #* #IMPORT MODULE #@pathToModule -- either relative or absolute (full) path def importModule(pathToModule, ext = '*.py'): import os import glob import imp path = os.path.join(pathToModule, ext) #iterate all files for infile in glob.glob(path): basename = os.path.basename(infile) basenameWithoutExtension = basename[0:-3] imp.load_source(basenameWithoutExtension, infile) #* #LOAD MODULE #TODO NOT WORKING YET #def loadModule(submodule, pathTo): # import imp #preparation # parts = pathTo.split('/') # moduleDir = parts[len(parts) - 2] # moduleFile = parts[len(parts) - 1] # # filenameParts = moduleFile.split('.') # fileName = filenameParts[0] # #moduleExt = filenameParts[len(filenameParts) - 1] #first load parent module # pathToDir = '/'.join(parts[0:len(parts) - 3]) # thefile, pathname, description = imp.find_module( # moduleDir, [pathToDir + ''] # ) # moduleDirObj = imp.load_module(moduleDir, thefile, pathname, description) # globals() [moduleDir] = moduleDirObj #now load the module to be loaded # thefile, pathname, description = imp.find_module( # fileName, [moduleDir] # ) #moduleObj = imp.load_source(module, thefile, pathname, description) # moduleObj = imp.load_module(submodule, thefile, pathname, description) # globals() [submodule] = moduleObj #so that it can be reached #TODO NOT WORKING YET (perhaps the above approach is better) def loadClass(className, pathToWithFile): import imp #two modi: # (1) path includes file => load # (2) file is first argument, path includes no file parts = pathToWithFile.split('.') partsL = len(parts) ext = parts[partsL - 1] parts = parts[0].split('/') partsL = len(parts) #refresh! pathToFile = '/'.join(parts[0:partsL - 2]) fileDir = parts[partsL - 2] fileName = parts[partsL - 1] #par = loadModule(fileName, pathToFile) thefile, pathname, description = imp.find_module( className, [pathToFile + '/' + fileDir + '.' + ext] ) return imp.load_module(className, thefile, pathname, description) #LOAD MODULE def loadModule(fileName, pathTo, globalIndex = ''): import imp thefile, pathname, description = imp.find_module( fileName, [pathTo] ) #moduleObj = imp.load_source(module, thefile, pathname, description) moduleObj = imp.load_module(globalIndex, thefile, pathname, description) if (globalIndex != ''): globals() [globalIndex] = moduleObj #so that it can be reached return moduleObj |