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

Fix "OSError: Unable to find libfuse" on Windows and Optimized the code and fixed other bugs #993

Merged
merged 43 commits into from
May 12, 2024

Conversation

ColdWindScholar
Copy link
Contributor

@ColdWindScholar ColdWindScholar commented May 4, 2024

a99d22a8ca991ffa4217b8ffc67d2632
This error occurs on Windows when Winfsp is not installed, And Its only need two dlls to fix it

@ColdWindScholar
Copy link
Contributor Author

ColdWindScholar commented May 4, 2024

Great, before I knew it, I had modified so much code, hahaha😄

@ColdWindScholar
Copy link
Contributor Author

ColdWindScholar commented May 4, 2024

Why not use lambda for buttons?🤔🤔

@ColdWindScholar
Copy link
Contributor Author

ColdWindScholar commented May 4, 2024

i think parser.print_help() is better than showcommands() 😐

@ColdWindScholar
Copy link
Contributor Author

ColdWindScholar commented May 4, 2024

\" is not easy to let human to read 😊

@ColdWindScholar
Copy link
Contributor Author

{} is dict , not object 😒

@ColdWindScholar
Copy link
Contributor Author

ColdWindScholar commented May 4, 2024

587558f8baace9da93054a4b8d5338c9
why self.reg.CQDMA_EN = [1] , it not runable!😥
file path is mtkclient\Library\Hardware\cqdma.py, i think its a bug, but dont know the purpose of this code ,so i cannot fix now

@Joshua-Larson
Copy link

Worked for me. Thanks a lot.

@hopez13 hopez13 mentioned this pull request May 8, 2024
@commonuserlol
Copy link

wtf is going here, PR was about fix windows error and now this guy refactoring whole repo 💀

@ColdWindScholar
Copy link
Contributor Author

wtf is going here, PR was about fix windows error and now this guy refactoring whole repo 💀

Just Optimized the code and fixed other bugs

@ColdWindScholar
Copy link
Contributor Author

why not merge PR

@commonuserlol
Copy link

I think you should do other PR for fixes and cleanup, or just rename this one

@commonuserlol
Copy link

like "major cleanup" or smth

@Joshua-Larson
Copy link

Yeah this should be like 2 or 3 different PR's. Maybe even more than that. I would say make a PR with only what is absolutely necessary for the libfuse fix and then make a separate PR with the rest of the optimizations. Generally you want to keep PR's as precise to the problem as possible.

@ColdWindScholar ColdWindScholar changed the title Fix "OSError: Unable to find libfuse" on Windows Fix "OSError: Unable to find libfuse" on Windows and Optimized the code and fixed other bugs May 11, 2024
@bkerler
Copy link
Owner

bkerler commented May 12, 2024

Yeah, this is a very bad PR. You need to separate "beautify", "cleanup" and "Fix for fuse". I will review it, but it will take some time.

@ColdWindScholar
Copy link
Contributor Author

ColdWindScholar commented May 12, 2024 via email

@bkerler bkerler merged commit 491f930 into bkerler:main May 12, 2024
1 check passed
@anthonymesa
Copy link

Using this fix does not fix the issue for me. I am on Windows 11. This issue persists on the pr/993 branch as well as main, where it has been merged. I have also installed winfspy individually, but given that the dll's were included in the commit f8ced92, I figure that shouldn't be an issue. I also notice that rather it being an issue with 'libfuse' here it is just fuse itself, though the contents of the requirements.txt does include fusepy and I have ensured it is installed on my system. Does anyone have any insight as to what the issue might still be?

~\Documents\Applications\mtkclient> git pr 993                                                      06/05/24 13:45:41 PM
Already on 'pr/993'
~\Documents\Applications\mtkclient> python mtk_gui                                                  06/05/24 13:45:49 PM
Traceback (most recent call last):
  File "C:\Users\admes\Documents\Applications\mtkclient\mtk_gui", line 18, in <module>
    from mtkclient.Library.DA.mtk_da_handler import DA_handler
  File "C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\DA\mtk_da_handler.py", line 12, in <module>
    from mtkclient.Library.Filesystem.mtkdafs import MtkDaFS
  File "C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem\mtkdafs.py", line 8, in <module>
    from fuse import Operations, LoggingMixIn
ModuleNotFoundError: No module named 'fuse'
~\Documents\Applications\mtkclient>  

@bkerler
Copy link
Owner

bkerler commented Jun 5, 2024

@anthonymesa What does python.exe -c "import os;print(os.environ.get('FUSE_LIBRARY_PATH'));print(os.name)" return ?

@anthonymesa
Copy link

anthonymesa commented Jun 5, 2024

That prints:

PS C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem> python.exe -c "import os;print(os.environ.get('FUSE_LIBRARY_PATH'));print(os.name)"
None
nt

So the FUSE_LIBRARY_PATH isn't already set, but I found when I was looking at mtkdafs.py earlier these lines:

if not os.environ.get('FUSE_LIBRARY_PATH') and os.name == 'nt':
    os.environ.setdefault('FUSE_LIBRARY_PATH', os.path.join(os.path.dirname(__file__), r"bin\winfsp-%s.dll" % ("x64" if sys.maxsize > 0xffffffff else "x86")))
from fuse import Operations, LoggingMixIn

So I tried in the repl to ensure that the path being generated was created correctly (replacing FILE with getcwd), and it does seem to be creating the correct env variable:

>>> print('FUSE_LIBRARY_PATH', os.path.join(os.getcwd(), r"bin\winfsp-%s.dll" % ("x64" if sys.maxsize > 0xffffffff else "x86")))
FUSE_LIBRARY_PATH C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem\bin\winfsp-x64.dll

All of this said, I did find that after using pip3 show fusepy, it is listed as being installed in my lib/site-packages directory, but looking in there, I find that there isn't a fusepy folder, just a dist info folder, so I tried uninstalling and re-installing to no avail:

PS C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem> pip3 uninstall fusepy
Found existing installation: fusepy 3.0.1
Uninstalling fusepy-3.0.1:
  Would remove:
    c:\python312\lib\site-packages\fusepy-3.0.1.dist-info\*
Proceed (Y/n)? y
  Successfully uninstalled fusepy-3.0.1
  
PS C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem> pip3 install fusepy
Collecting fusepy
  Using cached fusepy-3.0.1-py3-none-any.whl
Installing collected packages: fusepy
Successfully installed fusepy-3.0.1

PS C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem> python3
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.executable)
C:\Users\admes\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\python.exe
>>> import fusepy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'fusepy'

Even after re-installing it, fusepy specifically is not generating its proper package folder in site-packages, thus why it isn't being found. I am unsure how to resolve this going forward, as I do not primarily work with python nor am I well versed in pip. I did try to reinstall without cache, which also didn't work pip3 install --no-cache-dir fusepy

Thank you for your quick responses.

@anthonymesa
Copy link

Well, I did find that fusepy does seem to have installed, I was expecting a directory, but it is a file instead, I was alerted as I went to uninstall it, though even after verifying that file exists, I simply can not get python to import it.

PS C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem> pip3 uninstall fusepy
Found existing installation: fusepy 3.0.1
Uninstalling fusepy-3.0.1:
  Would remove:
    c:\python312\lib\site-packages\fuse.py
    c:\python312\lib\site-packages\fusepy-3.0.1.dist-info\*
Proceed (Y/n)? n

PS C:\Users\admes\Documents\Applications\mtkclient\mtkclient\Library\Filesystem> python3
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> fusepy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'fusepy' is not defined
>>> import fusepy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'fusepy'
>>> import fuse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'fuse'
>>> import fusepy.py 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'fusepy'
>>>

@bkerler
Copy link
Owner

bkerler commented Jun 5, 2024

I think you should rule out python issues by 1. use virtualenv or venv instead of system install and 2. use python 3.11 and not python 3.12 as the latter is the root for many issues right now

@anthonymesa
Copy link

That fixed it! Thank you so much for your time.

@ontimond
Copy link

This problem is also present on Mac OS, libfuse is only compatible with linux systems

@ontimond
Copy link

This problem is also present on Mac OS, libfuse is only compatible with linux systems

My bad. fusepy will try to search the macfuse library instead : )

@terminator850
Copy link

windows11 ,python3.11,

(MTK3) PS D:\source\3rd_tools\mtkclient_offical> python .\mtk.py printgpt        
Traceback (most recent call last):
  File "D:\source\3rd_tools\mtkclient_offical\mtk.py", line 5, in <module>
    from mtkclient.Library.mtk_main import Main, metamodes
  File "D:\source\3rd_tools\mtkclient_offical\mtkclient\Library\mtk_main.py", line 18, in <module>
    from mtkclient.Library.DA.mtk_da_handler import DaHandler
  File "D:\source\3rd_tools\mtkclient_offical\mtkclient\Library\DA\mtk_da_handler.py", line 12, in <module>
    from mtkclient.Library.Filesystem.mtkdafs import MtkDaFS
  File "D:\source\3rd_tools\mtkclient_offical\mtkclient\Library\Filesystem\mtkdafs.py", line 2, in <module>
    from fuse import Operations, LoggingMixIn
  File "C:\Users\admin\Apps\miniconda3\envs\MTK3\Lib\site-packages\fuse.py", line 115, in <module>
    raise EnvironmentError('Unable to find libfuse')
OSError: Unable to find libfuse
(MTK3) PS D:\source\3rd_tools\mtkclient_offical> python.exe -c "import os;print(os.environ.get('FUSE_LIBRARY_PATH'));print(os.name)"
None
nt

I have no idea,please help me.thank you.

@terminator850
Copy link

may be it was fixedby #1059

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

Successfully merging this pull request may close these issues.

7 participants