Python 2 Syntax Error Encountered in Python 3 Environment with ape Tool

81 Views Asked by At

I'm encountering an issue with the eth-ape tool in Python 3.9.17.

Hello, I am currently facing a problem with the eth-ape tool in Python 3.9.17. Although I have installed it successfully, I am encountering a syntax error related to the 'print' statement, which is commonly associated with Python 2 syntax. Here is the error message I received:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/ape", line 6, in <module>
    from ape.main import main
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ape/__init__.py", line 109
    print inspect.getdoc(self._tasks)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

I am confused about why this issue is happening since I am using Python 3 to run eth-ape. Here is the version of Python I am using:

python --version
Python 3.9.17

And I have confirmed that eth-ape is installed in my Python 3 environment:

python3 -m pip install eth-ape
Requirement already satisfied: ape in ./env/lib/python3.9/site-packages (0.4.0)
Requirement already satisfied: featuremonkey>=0.2.2 in ./env/lib/python3.9/site-packages (from ape) (0.3.1)

below is my deloy.py code:

from brownie import accounts


def deploy_simple_storage():
    account = accounts[0]
    print(account)


def main():
    deploy_simple_storage()

Can someone please help me find a solution to this problem? I would greatly appreciate any suggestions or guidance provided. Thank you in advance!

2

There are 2 best solutions below

3
Chris On

print in Python 3 requires parentheses.

>>> print "foo"
  File "<stdin>", line 1
    print "foo"
              ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("foo")?
>>> print("foo")
foo

Whereas it's perfectly valid in Python 2 to elide the parentheses.

>>> print "foo"
foo
4
user2357112 On

No release of ape has ever supported Python 3. It's also a dead project, with the last release in 2014 and the last activity on the repository in 2017, so no release is ever going to support Python 3.

I am confused about why this issue is happening since I am using Python 3 to run ape.

Yes, which is why ape's Python 2-only syntax isn't working.

From the comments, we can see that ape isn't actually the project you're looking for. You want the completely unrelated package eth-ape. Uninstall ape and install that.