Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'collections' has no attribute 'Callable' #49

Closed
derpieler opened this issue Sep 30, 2022 · 20 comments
Closed

AttributeError: module 'collections' has no attribute 'Callable' #49

derpieler opened this issue Sep 30, 2022 · 20 comments
Assignees
Labels

Comments

@derpieler
Copy link

Hi,
I get the above error message when I want to use the filetag script from the Sentto menu. Can I solve this myself?
Many greetings
Christian

Bild_2022-09-30_210645753

@novoid novoid self-assigned this Oct 1, 2022
@novoid
Copy link
Owner

novoid commented Oct 1, 2022

Hi,
Thanks for submitting the bug.

This is a tough one as it seems to be an issue with the library "pyreadline" which I'm using to read user input. If this is a pyreadline issue, I most probably can't help you.

Next week I may be able to access a Windows machine in order to try to recreate your issue (or not).

What was your installation method of choice? pip?

@derpieler
Copy link
Author

yes, pip.
I first ran pip install pypiwin32 and then:

pip install date2name appendfilename filetags integratethis.

I have never worked with github before. That's why I got the idea if I should have downloaded the package via the green code button first?

@novoid
Copy link
Owner

novoid commented Oct 1, 2022

Pip is fine if you don't plan to modify the code yourself although I sometimes am lazy with updating the packages - I accept reminders for that ;-)

So your setup does seem to be fine. I'll try to do the same in a Windows VM next week.

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 2, 2022

@derpieler Affirmative, the roadblock is seen e.g., in Windows 10 Home (32bit) and Python from python.org (Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 13:51:36) [MSC v.1933 32 bit (Intel)] on win32) though the installation of filetags (like e.g., date2name) did not report back problems to cmd.exe. When using the entry send to in the pull down menu, the context menu is shown; however this briefly (compared to date2name) that an input to provide a tag is not possible.

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 2, 2022

@novoid Thanks to WinPython, a Python interpreter one may carry on a thumbdrive which does not need to nest into the Windows operating system .and. offers a separate Python command line I knew from an other project it is possible to narrow the problem. Their package of Python 3.9.10 for Windows (32 bit) as distributed here so far is the most recent portable Python allowing to run filetags in Windows again.

Not knowing how comfortable @derpieler is to work from the CLI of such a guest system to reach for the host system, I'm on my way for a separate description for the OP.

@novoid
Copy link
Owner

novoid commented Oct 2, 2022

@nbehrnd does this mean the mentioned problem exists only in certain Python versions of Windows? Did I understand it correctly?

And: date2name doesn't use user input and doesn't use pypiwin32. Comparing with filetags in context of this bug doesn't help from my point of view.

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 2, 2022

@derpieler You possibly encounter an issue in Python 3.10.X reported earlier elsewhere. I do not know when the underlying problem will be resolved, it is outside filetags.

Just returning from a session in Windows 10 (32 bit) where I got filetags to work well, I recommend the following sequence of actions; basically, you start from a clean slate again.

  • deinstall of Python 3.10. Note that Windows' software management will mention two entries for Python, both the interpreter and an input environment; deinstall all Python-related entries.
  • python.org allows to access the installers of previous releases. Because version 3.9.10/32 bit was the most recent I identified to work with filetags, select version 3.9.10 (Release Date: Jan. 14, 2022), Windows installer (32 bit) as offered in the lower section here. Run the installation, this offers you both the interpreter, an input environment/IDLE, and pip.
  • Because the OS you use is Windows, run pip install pypiwin32 once from the cmd.exe
  • you have to remove the .bat files integratethis wrote. In case you already got date2name, time2name, etc -- remove all of them for now. If your user name would be Paul you find them in the path
    C:/User/PaulAppData/Roaming/Microsoft/Windows/SendTo (you likely have to manually enter AppData in the file manager's address line, typically this folder is hidden when displaying the content of drive C:). Depending on the language of installation, User may be named differently (e.g., Benutzer).
  • Then install again the scripts Karl wrote, so from cmd.exe
pip install date2name integratethis
pip install time2name integratethis
pip install filetags integratethis

and render them accessible again to the SendTo menu by

integratethis date2name
integratethis time2name
integratethis filetags

In my case, this allows the three entries in Windows' SendTo (date2name, time2name, filetags) to work. In case of filetags, it now offers enough time to enter a tag.

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 2, 2022

@novoid

  • Affirmative, observations suggest the problem might depend on the Python interpreter. The portable distribution for Python 3.9.10 (32 bit) by WinPython was the first environment I identified to run filetags in Windows 10/32 bit. For this I copied its __init.py__ on the Desktop and named it filetags.py. For the subsequent test, I cd'ed to D:$username\Desktop (because in my case, WinPython's Python command line is recognized as drive G:) and then run python filetags.py --help. The same did not work with Python 3.10.7 (32bit) downloaded from python.org and installed into Windows 10. This is why I then deinstalled Python 3.10.7, and installed Python 3.9.10 (32bit) by python.org. Since this is working fine, «something relevant happened» between 3.9.10 and 3.10.7; however I can not say which intermediate release introduced the bump in the road.

  • .True., filetags states «On Microsoft Windows (only), you are going to need pip install pypiwin32 as prerequisite.» An erroneous blend of my part.

@novoid
Copy link
Owner

novoid commented Oct 2, 2022

  • .True., filetags states «On Microsoft Windows (only), you are going to need pip install pypiwin32 as prerequisite.» An erroneous blend of my part.

Unfortunately, Windows does need much extra-effort for its technological stack. So far, I didn't encounter anything that was better on Windows. YMMV.

Either way, I am pretty sure that this is no filetags issue. It is either a readline library issue (more likely) or a Python interpreter issue (less likely). I'm closing this issue here for now. Of course, if you've got new insight on this topic, feel free and comment below.

Thanks for your contributions!

@derpieler
Copy link
Author

Thanks you very much for your help. I'm using win 10 pro 64 bit and installed python per chocolatey. I will test your solution and give feedback

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 5, 2022

@derpieler The early speculation by @novoid likely found independent confirmation in a discussion on python-forum.de. If possible for your workflow, wait a second and let Karl check pending PR50 which could resolve the issue, including an update of filetags on pypi.

If Karl's checks are passed well and if he is fine with the change introduced, you could proceed by an update; in the specific case, the required command is going to be

pip install --upgrade filetags

@novoid
Copy link
Owner

novoid commented Oct 5, 2022

Thanks @nbehrnd for all the effort you invested in the research!

I do have a busy week and can't test the issue or update the package on pypi before the weekend.

@novoid
Copy link
Owner

novoid commented Oct 9, 2022

I have just published the most current filetags version as https://pypi.org/project/filetags/2022.10.9.1/

@derpieler please write me if that doesn't fix your issue.

@derpieler
Copy link
Author

Thanks for your effort. A 'pip install date2name appendfilename filetags integratethis --upgrade' did upgrade. However, the same error message still appears.
I can test again later what happens if I remove the current installation as described by @nbehrnd. Or alternatively test another fresh computer.

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 10, 2022

@derpieler filetags relies on some modules which are not included in the «standard library» of Python (by python.org). It is possible your Python installation (by chocolately you mentioned) equally defaults to the core modules (like os, or shutil, etc.) to provide you a starter kit, too. To resolve these extra dependencies, file requirements.txt provides a list what pip should check and -- if not yet installed -- fetch from pypi.org .and. install when running the setup for filetags.

In this context of an installation of Python (from python.org) in Windows 10, I observed:

  • Initially, the pip-based installation of filetags (old version 2022.9.16.1) following the instructions/the documentation did not report an error during the installation. However, the temporary window to define a tag was not ready for use (matching your observation for Windows).
  • Second, file requirements.txt (current version, edit [2022-10-05 Wed] on GitHub) now resolves the dependencies better, than earlier. In one case, it was possible to get the old version (2022.9.16.1 from pypi, likely the one you still have on your computer) working by 1) copy-paste of new version file requirements.txt to the Windows desktop, 2) open cmd.exe, 3) with the cd command, to navigate to this location/folder, and 4) to run the command
pip install -r requirements.txt

Step 4) reaches out for pypi.org and internet connection is required. Perhaps no longer necessary, I then rebooted Windows altogether; however filetags eventually was functional. Following this sequence may be faster than deinstallation and manual edit of the (normally hidden) AppData folder and starting from scratch; it assumes your earlier installation of filetags did not report an error to cmd.exe.

You recognize the current version of requirements.txt by the line pyreadline3. For ease of replication, a copy of this file is attached below.

requirements.txt

@novoid
Copy link
Owner

novoid commented Oct 10, 2022

@nbehrnd I just realized that https://github.com/novoid/filetags/blob/master/filetags/__init__.py is still importing readline and not (py)readline3. Without looking too long, I could not determine if this is OK.

In my case, I now do have pyreadline as well as pyreadline3 installed. How is Python deciding which library to load? Does it require modification of the import statement to clarify on the library to use which hasn't been done yet?

@nbehrnd
Copy link
Contributor

nbehrnd commented Oct 11, 2022

@novoid My PR about requirements.txt spurs off the recommendation in said Python forum, followed by a manual adjustment of this file .and. subsequent use with pip. Because pyreadline3 on pypi[1] explicitly states to continue with functionality for Python 3.5+ previously offered by pyreadline[2] («Version 2.1 of pyreadline has been verfied for Python 2.7, and 3.4, 3.5.»)
and observation that filetags eventually was working lead to the assumption this may resolve the problem for good; given the record of the more senior module, the developers of the newer module use the same keywords to interface the core modules.

I would like to note both modules .zip/.tar.gz carry a file readline.py. Assuming the order of imports in the header in this file does not matter here, the earlier assumption «that's it, problems possibly resolved» is supported by the observation that both versions of this file only differ in function later

import pyreadline.console as console  # old form
import pyreadline3.console as console  # new form

in the inspection by kdiff3 (1.9.6). So my speculation is if using Debian 12/bookworm with running Python 3.10.7 (main, Sep 8 2022, 14:34:29) [GCC 12.2.0]) the documentation (by import readline; help(readline)) closing by

FILE
    /usr/lib/python3.10/lib-dynload/readline.cpython-310-x86_64-linux-gnu.so

is not too much surprising. I still have to check why both import pyreadline and import pyreadline3 fail in my installation though filetags definitively is working fine.

  1. https://pypi.org/project/pyreadline3/
  2. https://pypi.org/project/pyreadline/

2022-10-11_diff_pyreadline.zip

@novoid
Copy link
Owner

novoid commented Oct 12, 2022

So I guess it might be the case that a python3 -m pip uninstall pyreadline is recommended to get rid of the previous dependency which is not required any more after being replaced by pyreadline3.

@derpieler
Copy link
Author

derpieler commented Nov 1, 2022

Please excuse my late reply.
The workaround with requirements.txt worked. filetags now works for me. Unfortunately I have also not yet found a way to call the sentTo entries via hotkey.
I have found out however that there is in Irfanview the possibility to call 3 external programs.
image
The hotkey for this is then shift + 1,2 or 3.
image
Unfortunately, the file name is not automatically adjusted. If you then want to move the file, it is not found. I call the internal explorer of the program (hotkey t) and edit the files from there. After renaming I change the directory briefly and back again and can then begin with the moving.
image

Something else. Is there a good workflow to tag files downloaded from Twitter for example with the source. So for example download an image from Twitter, in case it doesn't exist later and link somewhere to the tweet to be able to use the source later alternatively.

@nbehrnd
Copy link
Contributor

nbehrnd commented Nov 2, 2022

@derpieler Is there any combination of letters, characters, Ctrl, Shift and Alt IrfanView did not yet assign to an action? Well, of course the addition of IrfanView as a program known to interact with Karl's utilities date2name, filetags, move2archive well as e.g., geeqie would be nice. Is «editor» (on your first screen photo) used by IrfanView to launch an other program to access and alter the content of an illustration (like pinta)/of text (like notepad++), or any (unrelated) program (e.g., a spread sheet program)?

A constraint visit of the program's user forum yields this exchange by [2021-12-01 Wed] suggesting the relay of the commands may include parameter flags (like datename --short %f one could imagine for the addition of a shortened timestamp, an approach I did not test yet in Windows), too. Maybe this can be extended to open the widget to select a tag (for filetags).


Your second question around Twitter taps into the territory of Memacs. Though unable to name which one, one of the youtube videos preserving Karl's talks at Grazer Linuxtage (GLT) around orgmode/PIM described the approach in lines of «not only that I remember when I visited the internet, and my notes, there equally is a local copy of the site visited». (This is a bit like a personal instance of the waybackmachine on archive.org.) If I remember correctly, tagging then was demonstrated as an approach to retrieve the information from a running instance of org-mode, i.e. thanks to org-mode tags in the .org file. However no, I do not have user experience with Memacs' Twitter module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants