MicrosoftLearning / mslearn-openai

https://microsoftlearning.github.io/mslearn-openai/
MIT License
214 stars 325 forks source link

Lab4: code-generation.py not finding sample code #70

Closed scottrhay closed 4 months ago

scottrhay commented 4 months ago

Module: 00

Lab/Demo: 00

Task: 00

Step: 00

Description of issue In Lab4, the python script could never find the function.py file.

Note I am running this on my local machine.

Repro steps: Run the script and choose #1, enter in a prompt, and it will return err 2

Resolution I added in the following code which changed my working folder to the folder containing the lab 4 script:

            # Change the current working directory to the script's directory
            script_directory = os.path.dirname(os.path.abspath(__file__))
            os.chdir(script_directory)
ivorb commented 4 months ago

I'm guessing this is due to running the script from the wrong directory, since it looks at a relative location from where the script is running. If using VS Code, be sure to open an integrated terminal in the right folder path. You should run the python script from where the code-generation.py file lives. If that doesn't work, please open a new issue with more details - best would be to use the hosted environments available in the Learn modules to ensure environment consistency

scottrhay commented 4 months ago

You are correct. Upon closer examination, I realized I had overlooked the second step in "Configure your application," which directs the student to right-click the 04-code-generation folder and open an integrated terminal. Thanks!