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

ctypes.cdll error #25

Open
gvossos opened this issue Mar 14, 2024 · 3 comments
Open

ctypes.cdll error #25

gvossos opened this issue Mar 14, 2024 · 3 comments

Comments

@gvossos
Copy link

gvossos commented Mar 14, 2024

Hi, I'm unable to run sample scripts on Windows 11 using Python 3.11.8.

Python throws --> ctypes.CDLL(lib_path) error,
--> musiclang\Lib\ctypes_init_.py", line 376, in init
self._handle = _dlopen(self._name, mode),
--> FileNotFoundError: Could not find module '....\musiclang\Lib\site-packages\musiclang_predict\c\run.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Any suggestions?

@GamingDaveUk
Copy link

Same issue.
windows 11.
git cloned the repo
cd'd into it
created a virtual environment: python -m venv venv
activated the environment: venv\Scripts\activate
created a test.py with the github basic script contents word for word.
ran it and after it downloaded the model etc I got:

(venv) D:\AI\musiclang_predict>python test.py
Traceback (most recent call last):
  File "D:\AI\musiclang_predict\test.py", line 9, in <module>
    score = ml.predict(
  File "D:\AI\musiclang_predict\musiclang_predict\predict.py", line 68, in predict
    generated_text = run_transformer_model(
  File "D:\AI\musiclang_predict\musiclang_predict\chelpers.py", line 19, in run_transformer_model
    lib = load_library()
  File "D:\AI\musiclang_predict\musiclang_predict\chelpers.py", line 12, in load_library
    return ctypes.CDLL(lib_path)
  File "C:\Program Files\Python310\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'D:\AI\musiclang_predict\musiclang_predict\c\run.dll' (or one of its dependencies). Try using the full path with constructor syntax.

I noticed in the readme it says to pip install it rather than clone it. so i tried that with a freshfolder, fresh virtual environment and got the following error:

 Running setup.py install for musiclang-predict ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Program Files\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\mrgre\\AppData\\Local\\Temp\\pip-install-wm0d7_rn\\musiclang-predict_24899c5f909b4853b8c3943ef01a8f26\\setup.py'"'"'; __file__='"'"'C:\\Users\\mrgre\\AppData\\Local\\Temp\\pip-install-wm0d7_rn\\musiclang-predict_24899c5f909b4853b8c3943ef01a8f26\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\mrgre\AppData\Local\Temp\pip-record-1b8gsgpe\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\mrgre\AppData\Roaming\Python\Python310\Include\musiclang-predict'
         cwd: C:\Users\mrgre\AppData\Local\Temp\pip-install-wm0d7_rn\musiclang-predict_24899c5f909b4853b8c3943ef01a8f26\
    Complete output (5 lines):
    running install
    running build
    running build_py
    error: [WinError 2] The system cannot find the file specified
    is called install
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Program Files\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\mrgre\\AppData\\Local\\Temp\\pip-install-wm0d7_rn\\musiclang-predict_24899c5f909b4853b8c3943ef01a8f26\\setup.py'"'"'; __file__='"'"'C:\\Users\\mrgre\\AppData\\Local\\Temp\\pip-install-wm0d7_rn\\musiclang-predict_24899c5f909b4853b8c3943ef01a8f26\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\mrgre\AppData\Local\Temp\pip-record-1b8gsgpe\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\mrgre\AppData\Roaming\Python\Python310\Include\musiclang-predict' Check the logs for full command output.

Side note: when going to get the error code again to share here, I forgot to activate my virtual environment.... that may end up being a costly mistake... time will tell but it does show its not the virtual environment effecting it.

@floriangardin
Copy link
Contributor

I don't currently own a windows laptop so it's hard for me to debug that.
I don't know if the setup is failing for everyone on this os. If someone managed to get it to work on windows it would be great to let me know. Otherwise I am adding a disclaimer section on the readme.

If you clone it instead of pip install : you need to build the C dependencies (used for faster inference) yourself.
You need a C compiler, and there is a makefile in musiclang_predict/c directory, it will build the lib. You can check the setup.py to see what is happening during the setup.

I will work for a more robust setup, but if someone want to give a hand, it would be wonderful !

@gvossos
Copy link
Author

gvossos commented Mar 20, 2024

Thanks for the note Florian. Yes - hoping someone can help out. For reference, I went down the pip install route.

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