module import "name is not defined" [solved]

Hello again, I have been experimentating on splitting my game code into several separated .py files, after a lot of research I managed to learn part of the process, but what happens now is the following:

import direct.directbase.DirectStart

from direct.gui.OnscreenImage import OnscreenImage
from pandac.PandaModules import PandaNode, LightNode, TextNode, NodePath, Camera
from pandac.PandaModules import Filename
from pandac.PandaModules import PointLight, AmbientLight
from pandac.PandaModules import LightRampAttrib, AuxBitplaneAttrib
from pandac.PandaModules import CardMaker
from pandac.PandaModules import Shader, Texture
from pandac.PandaModules import Point3,Vec2,Vec3,Vec4,BitMask32
from pandac.PandaModules import *

from direct.task import Task
from import Actor
from direct.interval.IntervalGlobal import *
from direct.showbase.DirectObject import DirectObject
from direct.filter.CommonFilters import CommonFilters
from direct.gui.OnscreenText import OnscreenText 

import random, sys, os, math


from graphics import * 


#GraphicsManager() is a class from
g = GraphicsManager()

The above code is from the main file(, in the same folder, the module can be found, I have managed to acess this module with from graphics import*, but then I get when running the code the following:

NameError: global name 'Actor' is not defined

I find it strange, as I have already imported all necessary things in, anyway I have even added from import Actor again in but to no use, any help is welcome. Below are parts of

Class which manages Graphics
class GraphicsManager():
	def __init__(self):
	def loadActor(self):						
		self.player = render.attachNewNode("player")         	
		self.playerActor = Actor.Actor(MYDIR+"/data/graphics/3D/player/player")
		self.player.setPos( -1.4,0,-1.1 )

Hey, and thanks for all the help you all gave me before, you´re truly patient.

Each separate file (“module”) is seen by Python as a separate namespace so you cannot refer to variables from in You are correct to add an import of Actor in your which should fix that specific error.
I tested your code and you should be getting an error, but for “MYDIR” not Actor. If you want to use MYDIR in you will need to either define it in the same way as in or pass it as a variable when instancing the GraphicsManager class.

You might find it useful to create a file for values you want to refer to in many Python files. So you might have something like:

MODEL_PATH = "assets/models/"
TEXTURE_PATH = "assets/textures/"

Now you can import this into any Python file and use the values:

import my_vars
model = loader.loadModel(my_vars.MODEL_PATH + "man")
texture = loader.loadTexture(my_vars.TEXTURE_PATH + "man.png")


modelPath = getModelPath()


model = loader.loadModel("man") 
texture = loader.loadTexture("man.png") 

Hi,I found my problem was really the Actor, i was using gedit, the problem was I moved my .py files to a new folder.When I opened gedit, then opened a recently modified file(the list above exit) modified and saved the file, gedit would recreate the files in their original location, but in terminal I was already running the .py files in the new folder, so, my saves weren´t going to where they needed to.

To solve this I just did a gedit “save as” of each file in their correct place, then gedit understood where it should save the files.

But your tips were very usefull too, thanks for the help!