Ich versuche, in Python zu beginnen und an einem einfachen Programm zu arbeiten, das die AIMA -Bibliothek verwendet. Ich habe die AIMA -Bibliothek importiert und alle Dateien sind in einem übergeordneten Verzeichnis enthalten. Ich habe ein Unterverzeichnis erstellt und in diesem Unterverzeichnis habe ich eine einzige .py -Datei. Dies sollte ermöglichen, dass die .py -Datei auf einem Computer ausgeführt werden kann, auf dem die AIMA -Bibliothek im übergeordneten Verzeichnis vorliegt. < /P>
# Get the parent directory of the current file and print the path for verification - alternative method to above
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
print(f"Parent dir is {parent_dir}")
# Add the parent directory to sys.path and print the path for verification
sys.path.insert(0, parent_dir)
print(f"Sys path is {sys.path}")
import agents
# Verify that the agents module has been imported successfully
print ('Successfully imported agents from AIMA library')
print("agents module:", agents)
print("Has TrivialVacuumEnvironment:", hasattr(agents, "TrivialVacuumEnvironment"))
class BlindDog(Agent):
def eat(self, thing):
print("Dog: Ate food at {}.".format(self.location))
def drink(self, thing):
print("Dog: Drank water at {}.".format( self.location))
dog = BlindDog()`
< /code>
Ausführen dieses Codes Ich hätte erwartet, dass das Agentenmodul korrekt eingerichtet wurde, damit der Blinddog -Agent definiert werden kann. Ich erhalte jedoch die Ausgabe unten, in der die Pfade korrekt definiert werden, aber ich erhalte immer noch einen Fehler. Ich denke, ich mache etwas wirklich grundlegend falsch, kann es aber an diesem Punkt nicht sehen.Parent dir is /Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python
Sys path is ['/Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python', '/Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python/Assignment_1', '/opt/anaconda3/envs/24COMP9016/lib/python39.zip', '/opt/anaconda3/envs/24COMP9016/lib/python3.9', '/opt/anaconda3/envs/24COMP9016/lib/python3.9/lib-dynload', '/opt/anaconda3/envs/24COMP9016/lib/python3.9/site-packages']
Successfully imported agents from AIMA library
agents module:
Has TrivialVacuumEnvironment: True
Traceback (most recent call last):
File "/Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python/Assignment_1/A1.py", line 38, in
class BlindDog(Agent):
NameError: name 'Agent' is not defined
Ich versuche, in Python zu beginnen und an einem einfachen Programm zu arbeiten, das die AIMA -Bibliothek verwendet. Ich habe die AIMA -Bibliothek importiert und alle Dateien sind in einem übergeordneten Verzeichnis enthalten. Ich habe ein Unterverzeichnis erstellt und in diesem Unterverzeichnis habe ich eine einzige .py -Datei. Dies sollte ermöglichen, dass die .py -Datei auf einem Computer ausgeführt werden kann, auf dem die AIMA -Bibliothek im übergeordneten Verzeichnis vorliegt. < /P> [code]# Get the parent directory of the current file and print the path for verification - alternative method to above parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) print(f"Parent dir is {parent_dir}")
# Add the parent directory to sys.path and print the path for verification sys.path.insert(0, parent_dir) print(f"Sys path is {sys.path}")
import agents
# Verify that the agents module has been imported successfully print ('Successfully imported agents from AIMA library') print("agents module:", agents) print("Has TrivialVacuumEnvironment:", hasattr(agents, "TrivialVacuumEnvironment"))
class BlindDog(Agent): def eat(self, thing): print("Dog: Ate food at {}.".format(self.location))
def drink(self, thing): print("Dog: Drank water at {}.".format( self.location))
dog = BlindDog()` < /code> Ausführen dieses Codes Ich hätte erwartet, dass das Agentenmodul korrekt eingerichtet wurde, damit der Blinddog -Agent definiert werden kann. Ich erhalte jedoch die Ausgabe unten, in der die Pfade korrekt definiert werden, aber ich erhalte immer noch einen Fehler. Ich denke, ich mache etwas wirklich grundlegend falsch, kann es aber an diesem Punkt nicht sehen.Parent dir is /Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python Sys path is ['/Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python', '/Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python/Assignment_1', '/opt/anaconda3/envs/24COMP9016/lib/python39.zip', '/opt/anaconda3/envs/24COMP9016/lib/python3.9', '/opt/anaconda3/envs/24COMP9016/lib/python3.9/lib-dynload', '/opt/anaconda3/envs/24COMP9016/lib/python3.9/site-packages'] Successfully imported agents from AIMA library agents module: Has TrivialVacuumEnvironment: True Traceback (most recent call last): File "/Users/brianbarry/Library/CloudStorage/OneDrive-Personal/Documents/Education/Artificial Intelligence PGradDip/Knowledge Representation/Labs & Assignments/AIMA Folder/aima-python/Assignment_1/A1.py", line 38, in class BlindDog(Agent): NameError: name 'Agent' is not defined [/code]
Ich erhalte diesen Fehler MODUL Lambda_Function : Kein Modul mit dem Namen 'Pil' , wenn ich versuche, eine AWS -Lambda auszuführen, die Pile verwendet. Ich habe die Datei entpackt, um die internen...
Ich kann keine Möglichkeit finden, Konfigurationsgruppenoptionen aus übergeordneten Verzeichnissen in Hydra zu laden.
e.g. Hier möchte ich die Konfigurationsgruppenoption von...
Ich mache eine React -App.
Ich verwende einen Python -Code, um ein paar Dinge zu automatisieren. Ich möchte dies vermeiden und alle meine gemeinsamen Python-Funktionen in eine Helferklasse...
Ich habe ein kleines Problem damit. Dachte, es wäre einfacher, aber es stellte sich als frustrierend heraus. Ich versuche lediglich, ein Textfeld zu haben, in das ich den Namen eines neuen...