问题
I recently installed Python 3.5.2 on Mac OS X El Capitan (Version 10.11.6). I (thought) I configured Aptana Studio 3 correctly so that it points at Python 3.5 when it runs any Python code. But I'm getting error messages even why I try to run simple commands.
If you take a look at the following screenshots:
You'll notice that printing(4+8) does print 12, but I get a red X to the left of the print command (which after hovering reveals "undefined variable: print"). I also get Traceback messages and TypeErrors. The same goes for when I try something more advanced, like creating a function and running tests:
I shouldn't be getting these error messages if Aptana is pointed at Python 3 correctly, right? You can see in the screenshots that Python 3.5 is in the same folder as the test.py file I'm using to run the code. I had followed this youtube tutorial to configure Python Interpreter in Aptana (she starts this around 1:30). Any help is greatly appreciated!
EDIT: Following these instructions on VectorWorks, I go to Preferences > PyDev > Interpreters > Python Interpreter and click on Advanced Auto-Config. The options that show up only include Python versions 2.6 and 2.7.
I don't understand why 3.5 isn't showing up? If I choose the second option under Python Interpreters (Python 1), it now displays Python 3 in the system library, but again when I click advanced auto config, it still only provides me with versions 2.6 and 2.7.
回答1:
I was getting error messages because Aptana Studio (along with every other IDE) doesn't support testEqual. TestEqual only works in Active Code, the text editor that we're using (online) for the class I'm currently enrolled in. After removing:
from test import testEqual
and
testEqual(
and then printing the sum_evens function:
print(sum_evens([2,3,4]))
The console prints the correct answer without any error messages.
来源:https://stackoverflow.com/questions/40981094/running-python-locally-in-aptana-studio-3