-1

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!

vookami
  • 1
  • 1
  • This question is odd. Your error clearly says you are using `print` as a statement on python 3 environment. There is no Python 2 Syntax Error, the issue is you are running python 2 `print` code on python 3. –  Aug 05 '23 at 05:03
  • The error is associated with code written in Python 2 syntax being loaded into a Python 3 interpreter -- which is exactly what you're doing here. – Charles Duffy Aug 05 '23 at 05:03
  • 1
    @R__i_ Thanks for your input. I get what you're saying - the error is popping up because I'm running Python 2 code in a Python 3 environment. But I'm seeing this error when I use the 'Ape Framework', and that's supposed to be all good with Python 3. So, I'm wondering if there might be some parts of the library or its dependencies that are still stuck in Python 2. I'm still on the hunt for a fix to this issue. – vookami Aug 05 '23 at 05:18
  • It looks like you just manually edited your question to pretend you installed `eth-ape`, without actually uninstalling `ape` and installing `eth-ape`. Your output would not look like that if you had uninstalled `ape` and installed `eth-ape`. – user2357112 Aug 05 '23 at 05:30
  • @user2357112 sorry about the change. the response was very long so I change the ape part only. anyway, I installed eth-ape at the first time rather than ape. sorry to confuse. – vookami Aug 05 '23 at 05:35
  • Look. It's really obvious that you actually installed `ape`, not `eth-ape`. You can't just post a Python error message clearly coming from [a specific, identifiable line of `ape`](https://github.com/henzk/ape/blob/0.4.0/ape/__init__.py#L109), with pip output clearly showing you have `ape` installed, and then try to edit in `eth-` in a few places and claim you never installed `ape`. – user2357112 Aug 05 '23 at 05:41
  • @user2357112 sorry to comfuse. I'm not a english native speaker, so i use chatGPT to help me write the question, i didn't aware that there is a other ape project. – vookami Aug 05 '23 at 05:46
  • Unless you just had ChatGPT make up your error message and pip output, the error message and pip output clearly indicate you installed `ape`. If you did have ChatGPT make all that up, then we've both wasted a bunch of time debugging a situation that never happened instead of debugging your actual problem. (Also, using ChatGPT to compose questions or answers is [banned](https://meta.stackoverflow.com/questions/421831/temporary-policy-generative-ai-e-g-chatgpt-is-banned?cb=1).) – user2357112 Aug 05 '23 at 05:49
  • sorry, i didn't know that it is banned, not a excuse but i started use this since yesterday. although except the install ape part, it was all true. i will delete this post and create a new post. thank you for mension. – vookami Aug 05 '23 at 05:56

2 Answers2

2

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.

user2357112
  • 260,549
  • 28
  • 431
  • 505
  • Thanks for your input. I think there's been a bit of a mix-up. The 'ape' I'm talking about is actually the 'Ape Framework'. It's a Web3 development tool created by ApeWorX LTD. This tool is pretty handy - it lets users compile, test, and interact with smart contracts all from a single command line session. It's designed to work with Python 3.8 and newer versions. I've got it installed on Python 3.9.17 using pip. But I'm getting a syntax error that's usually associated with Python 2 when I use this library. – vookami Aug 05 '23 at 05:13
  • @vookami: If that's the `ape` you want to use, then you installed the wrong thing. Uninstall `ape` and install [`eth-ape`](https://pypi.org/project/eth-ape/). – user2357112 Aug 05 '23 at 05:22
  • sorry, it was a misunsderstanding. I installed eth-ape rather than ape. change the question allready. thank you. – vookami Aug 05 '23 at 05:31
  • @vookami: "I installed eth-ape rather than ape." - all evidence points to that not actually being the case. – user2357112 Aug 05 '23 at 05:33
0

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
Chris
  • 26,361
  • 5
  • 21
  • 42
  • Thank you for your response. I acknowledge that in Python 3, the print function requires parentheses, distinguishing it from Python 2. However, my concern lies in encountering a Python 2 syntax error despite operating within a Python 3 environment. This issue specifically arises when utilizing the 'ape' library, despite confirming that I am indeed using Python 3.9.17. I am curious to understand the reasons behind this occurrence and seek guidance on resolving this problem. – vookami Aug 05 '23 at 05:03
  • @vookami It's not a Python 2 syntax error. This only ever was a Python 3 error. – Charles Duffy Aug 05 '23 at 05:05
  • @Chris, note the bullet point in the _Answer Well-Asked Questions_ section of How to Answer about questions that have been "asked and answered many times before". – Charles Duffy Aug 05 '23 at 05:07