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

Chapter 11 - Text Search - Weird exception being thrown #26

Open
cmcknight opened this issue Apr 25, 2019 · 13 comments
Open

Chapter 11 - Text Search - Weird exception being thrown #26

cmcknight opened this issue Apr 25, 2019 · 13 comments

Comments

@cmcknight
Copy link

cmcknight commented Apr 25, 2019

Never finds the config.ini. Always claims grin3 not installed even though it is and the config.ini file exists. Repo code has the same issue as the book code.

Mac OS 10.14.4
32G RAM
Python 3.7.3


Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Volumes/ProjectDrive/git-projects/Creating_GUI_Applications_with_wxPython/src/Chapter_11/text_search/search_thread.py", line 29, in run
output = subprocess.check_output(cmd, encoding='UTF-8')
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in init
restore_signals, start_new_session)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/Volumes/ProjectDrive/git-projects/Creating_GUI_Applications_with_wxPython/src/Chapter_11/text_search/config.ini'

-rw-r--r-- 1 chuck wheel 132B Apr 25 08:01 config.ini
-rw-r--r-- 1 chuck wheel 7.2K Apr 25 07:54 main.py
-rw-r--r-- 1 chuck wheel 2.6K Apr 25 07:44 preferences.py
-rw-r--r-- 1 chuck wheel 1.2K Apr 25 07:53 search_thread.py

@driscollis
Copy link
Owner

Hmmm. Works on Linux (Xubuntu 18.04) and Windows 7. I will have to try this on my Mac later

@driscollis
Copy link
Owner

Works on my Macbook Pro 10.14.4, Python 3.6.4. I do see this in stdout:

objc[11673]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/FinderKit (0x12a2df3c8) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x132108f50). One of the two will be used. Which one is undefined.

However, this error or warning does not seem to affect the running of the program at all.

Are you sure you are installing grin3 ?

@driscollis
Copy link
Owner

Looks like my warning has something to do with Tkinter - jarvisteach/appJar#285

I don't know why it shows up when running wxPython, but that thread mentions that PyQt5 is also causing that error to pop up, so maybe it just has something to do with GUI toolkits in general. Doesn't seem to affect anything though.

@cmcknight
Copy link
Author

cmcknight commented Apr 26, 2019 via email

@driscollis
Copy link
Owner

Hmmm. I will have to try creating a virtualenv then when I get a chance. Not sure why that would happen in that scenario though

@driscollis
Copy link
Owner

I created a virtualenv using Python's venv module. I installed wxPython, PyPubSub and ObjectListView in it and the text search code worked fine for me.

@cmcknight
Copy link
Author

cmcknight commented Apr 27, 2019 via email

@cmcknight
Copy link
Author

cmcknight commented Apr 27, 2019 via email

@driscollis
Copy link
Owner

I hate to ask this, but could you try with Python 3.6? I wonder if there is some weird incompatibility with 3.7. I don't have 3.7 on my Mac at the moment to test with.

@driscollis
Copy link
Owner

Windows 10 appears to work wit Python 3.7, although I am seeing this error in stdout:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "c:\Program Files (x86)\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\Users\mike\Downloads\applications_with_wxpython-master\applications_with_wxpython-master\chapter11_search_utility\text_search\search_thread.py", line 38, in run
    results[current_key].append(line)
KeyError: ''

I still get search results though.

@driscollis
Copy link
Owner

I went ahead and fixed the issue I mentioned finding on Windows 10

@driscollis
Copy link
Owner

FYI: I added Python 3.7 to my Mac and ran this code. I do get an error now that does not appear in 3.6. However, it is different from yours:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/grin", line 10, in <module>
    sys.exit(grin_main())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/grin.py", line 1263, in grin_main
    report = g.grep_a_file(filename, opener=openers[kind])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/grin.py", line 568, in grep_a_file
    unique_context = self.do_grep(f)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/grin.py", line 386, in do_grep
    block = self.read_block_with_context(None, fp, fp_size)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/grin.py", line 339, in read_block_with_context
    curr_block = (prev.data[prev.end:] + block_main + ('' if is_last_block else fp.readline()))
TypeError: can only concatenate str (not "bytes") to str
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/Users/michael/Dropbox/Books/Applications_with_wxPython/code/chapter11_search_utility/text_search/search_thread.py", line 29, in run
    output = subprocess.check_output(cmd, encoding='UTF-8')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.7/bin/grin', 'wx', '/Users/michael']' returned non-zero exit status 1.

This appears to be a grin bug, not one with my code. I do get some search results returned regardless of the error, although I don't know if I am getting all the results I should.

@tester0077
Copy link

Just downloaded the code for this same project and am trying to run it under VSCode 1.74.0 on Win10.
The problem I am running into is that selecting the grin.exe in the preferences dialog browser file selector never shows up in the preferences text control and hence I can never search for anything since the Save operation always fails with "Grin location not set!"
FWIW, the grin location is: C:\Users\arnold\AppData\Local\Programs\Python\Python39\Scripts\grin.exe

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

No branches or pull requests

3 participants