GithubHelp home page GithubHelp logo

Comments (11)

probabilityfilter avatar probabilityfilter commented on June 10, 2024 2

I am newbie when it comes to py5, have little Python experience but not at CS level. Introducing py5 and Thonny to my son. I enjoy your content on Twitter. I was able to follow the instructions here and install py5 via Thonny plugins and download JDK but when I run a sample code (from this repo), I get a similar error - cannot import name 'ASTText' from 'asttokens'. PS: I use a Windows laptop. Being a newbie, I might be approaching this 'error reporting' completely wrong! Let me know if there is something else I should be doing about this error:

Traceback (most recent call last): File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 52, in <module> main() File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 44, in main imported.run_code( File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 135, in run_code _run_code( File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 259, in _run_code _run_sketch(sketch_path, classpath, exit_if_error) File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 196, in _run_sketch import py5 File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5\__init__.py", line 84, in <module> from py5_tools.magics import load_ipython_extension # noqa File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\__init__.py", line 22, in <module> from .drawing import DrawingMagics, DXFDrawingMagic File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\drawing.py", line 27, in <module> from IPython.display import display, SVG, Image File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\__init__.py", line 51, in <module> from .core.application import Application File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\application.py", line 26, in <module> from IPython.core import release, crashhandler File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\crashhandler.py", line 27, in <module> from IPython.core import ultratb File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\ultratb.py", line 101, in <module> import stack_data File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\__init__.py", line 1, in <module> from .core import Source, FrameInfo, markers_from_ranges, Options, LINE_GAP, Line, Variable, RangeInLine, \ File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\core.py", line 19, in <module> from stack_data.utils import ( File "C:\Users\aramamoorthy\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\utils.py", line 11, in <module> from asttokens import ASTText ImportError: cannot import name 'ASTText' from 'asttokens' (C:\Users\aramamoorthy\AppData\Local\Programs\Thonny\lib\site-packages\asttokens\__init__.py)

from thonny-py5mode.

hx2A avatar hx2A commented on June 10, 2024 2

If you want to test the fix, I uploaded dev packages to test.pypi.org:

https://test.pypi.org/project/py5/0.9.0.dev0/#files

Thonny provides an option to install a python library from a wheel file. Download the wheel file and install using that feature, or with the command like pip install ./py5-0.9.0.dev0-py3-none-any.whl. Don't install directly from test.pypi.org directly, that can get messy.

from thonny-py5mode.

villares avatar villares commented on June 10, 2024 1

import name 'ASTText' from 'asttokens'**. PS: I use a Windows laptop. Being a newbie, I might be approaching this 'error reporting' completely wrong! Let me know if there is something else I should be doing about this error:

Hi @probabilityfilter !

I think I had a student with the same error! I'm afraid I don't understand the problem yet, sorry.

Can you try, from the Thonny menu "shell", pip3 uninstall py5 and then pip3 install py5[jupyter]?

Can you try this "portable" Thonny? https://www.dropbox.com/s/3ue4cx3yf372teg/thonny-4-with-py5-windows-portable.zip?dl=0

Otherwise this VM: https://drive.google.com/file/d/1L_h0gv87TGhawc2uTPfPk5tAm-XzldI4/view

Let's see if @py5coding has an insight about this ASTtokens import issue!

from thonny-py5mode.

hx2A avatar hx2A commented on June 10, 2024 1

Hello @probabilityfilter ! I am the maintainer of py5. I must have missed the @ mention from @villares back in November. I am reading this now.

The Python library asttokens is used for parsing syntax trees and syntax highlighting. It is not used by py5 but it might be used by Jupyter Notebook and/or JupyterLab.

py5 and the related library py5jupyter has support for Jupyter Notebooks. The two libraries were split about 6 months ago but there was still some deprecated code in py5.

This morning I made a long-awaited improvement to py5 to remove the deprecated code and completely separate py5 from Jupyter. After the next release, it will be possible to install py5 without also installing IPython or Jupyter. This will benefit Thonny users as installs will be simpler. In my test environments, I see that asttokens is not importable in my environment with py5 but is importable in my environment with both py5 and py5jupyter.

So I may have inadvertently solved this problem because py5 will no longer import any IPython libraries and therefore will not import asttokens.

The problem you faced before seems to have been a versioning issue, where IPython was looking for a newer or older version of asttokens. It might have been possible to fix it by installing a specific version of asttokens. I am confused why this problem took place. Somehow there was a versioning incompatibility issue in your environment.

The next release will be in January, probably.

from thonny-py5mode.

probabilityfilter avatar probabilityfilter commented on June 10, 2024 1

Awesome, thanks so much. This method worked! (download wheel file and run pip command from Thonny). Now I can restart teaching my son some cool Python code

from thonny-py5mode.

probabilityfilter avatar probabilityfilter commented on June 10, 2024

Thanks for the response. Unfortunately I am at the very beginning levels of 'behind the scene' actions but given enough time I can 'google' my way through :-) I copy pasted the first line you gave me and this is what I get. I will look into the error when I get some time during the weekend:
image

from thonny-py5mode.

villares avatar villares commented on June 10, 2024

Cheers @probabilityfilter !

image

Maybe pip will work, and pip3 will be the same (for me they are the same).

image

image

from thonny-py5mode.

probabilityfilter avatar probabilityfilter commented on June 10, 2024

hmm, for some reason it is saying py5 is not installed!!
image

I even changed the path where I run this
image

from thonny-py5mode.

villares avatar villares commented on June 10, 2024

Can you try this "portable" Thonny?
https://www.dropbox.com/s/3ue4cx3yf372teg/thonny-4-with-py5-windows-portable.zip?dl=0

from thonny-py5mode.

hx2A avatar hx2A commented on June 10, 2024

Great, I am glad it worked! I didn't realize what I was changing would resolve bugs but I am so glad it did.

That package I uploaded is for testing purposes. My goal is to do a release in January.

Have fun teaching your son Python!!

from thonny-py5mode.

villares avatar villares commented on June 10, 2024

Fixed! Let's close this 😄

from thonny-py5mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.