1

I am new to coding, and I just installed Python 3.7.1 and Wing IDE Personal 6.1 on my computer. I installed python first, then Wing IDE, and pointed Wing to python.exe through the project properties menu. Here's what shows up in the python shell when I start Wing IDE:

3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)]
Python Type "help", "copyright", "credits" or "license" for more information.

I wrote the following program:

def addFive(value):
    return 5 + value

Then saved and ran the program. I wrote in the shell "addFive(106)" and got the following error:

Traceback (most recent call last):
  Python Shell, prompt 3, line 1
builtins.NameError: name 'addFive' is not defined.

I took some code that I wrote on a school computer, where it ran as intended, and tried to run it on my home computer, where I received the same error. I tried multiple different simple functions. What's going on? Did I install Wing IDE/Python wrong? I know these programs work, so there must be something else going on.

closed as off-topic by Scott, fixer1234, BillP3rd, td512, LotPings Jan 25 at 14:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about computer hardware or software, within the scope defined in the help center." – Scott, fixer1234, BillP3rd, td512, LotPings
If this question can be reworded to fit the rules in the help center, please edit the question.

0

Did you import the program file so that python could find the function? Python can't find code buried in some random file, even if it's in the current directory.

Type

import filename

where filename is the name of the file containing the function, without the .py suffix. That loads the file into the interactive session.

  • When I tried that, I got the following error: import tester Traceback (most recent call last): Python Shell, prompt 7, line 1 builtins.ModuleNotFoundError: No module named 'tester' – Cody Crawford Jan 20 at 23:32
0

I figured it out, and I'm posting here in case anyone else has this problem and stumbles upon this post. I had to go to the "options" dropdown just above the python shell and select "evaluate [filename]". The line ">>>[evaluate [filename]]" appeared in the python shell, then I could run my program.

Not the answer you're looking for? Browse other questions tagged or ask your own question.