Open ghost opened 2 years ago
Also encountered a lot of errors and could not get it to compile on mac.
I would appreciate if the developers follow the requested suggestion from @blacklein about to add it in the releases page for macOS users (M1 and Intel)
+1 for Intel
Tested on Python 3.9.13 via pyenv Clone repo
git clone https://github.com/blawar/nut.git
cd nut
Create virtualenv
pyenv install 3.9.13
pyenv shell 3.9.13
python3 -m venv testnut
source testnut/bin/activate
install dependecies
brew install libusb curl openssl@3 pyqt@5
pip3 install wheel
pip3 install -r requirements.txt
make folder if there is no lib directory
mkdir /usr/local/lib
Link libusb to default bin diretory
ln -s /opt/homebrew/Cellar/libusb/1.0.26/lib/libusb-1.0.0.dylib /usr/local/lib/libusb.dylib
set curl env for current shell window
export LDFLAGS="-L/opt/homebrew/opt/curl/lib"
export CPPFLAGS="-I/opt/homebrew/opt/curl/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/curl/lib/pkgconfig"
set openssl env for current shell window
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
Copy pyqt@5 to virtualenv
brew info pyqt@5
sudo cp -R /opt/homebrew/Cellar/pyqt@5/5.15.7_2/lib/python3.9/site-packages/* ./testvenv/lib/python3.9/site-packages
install pyurl with openssl
pip3 uninstall pycurl
pip3 install --compile --install-option="--with-openssl" pycurl
Copy key.txt to nut working directory Run nut CLI
python3 nut.py
Show info if successful
python nut.py
loading blacklist /Users/chenzhiyu/Downloads/nut/conf/blacklist.online.txt
loaded user guest
,;:;;,
;;;;;
.=', ;:;;:,
/_', "=. ';:;:;
@=:__, \,;:;:'
_(\.= ;:;;'
`"_( _/="`
`"'
fin
Run nut GUI
python3 nut_gui.py
Show window if successful
@blacklein, I've got it working on my Intel machine thanks to your guide.
Almost all commands work, I've replaced all of /opt/homebrew/
for /usr/local
which should be correct. But sudo cp -R /opt/homebrew/Cellar/pyqt@5/5.15.7_2/lib/python3.9/site-packages/* ./testvenv/lib/python3.9/site-packages
errors with the following:
cp: ./testvenv/lib/python3.9/site-packages is not a directory
Understandable because I don't see the folder testvenv in the master folder. All other commands work and NUT seems to work well. Not sure if I miss something here? Just to be sure/safe.
For me, the only thing I have to do when I relaunch a terminal:
python3 -m venv testnut
source testnut/bin/activate
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"
export PKG_CONFIG_PATH="/usr/local/opt/curl/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
testnut is the name of virtual enviroment created for this project under nut folder, so it can be any name depends on what you use in python -m venv <name>
Ah I found the folder, thanks again. It weirdly works without it.
if you use oh-my-zsh
, you can echo
those export
commands into .zshrc
config file, so it will not need to export
everytime reboot terminal
if you use
oh-my-zsh
, you canecho
thoseexport
commands into.zshrc
config file, so it will not need toexport
everytime reboot terminal
I did, thanks!
Mac M1 OS: MacOS Monterey
I follow the solution of @blacklein then found this error when installing pycurl
Installing collected packages: pycurl
DEPRECATION: pycurl is being installed using the legacy 'setup.py install' method, because the '--no-binary' option was enabled for it and this currently disables local wheel building for projects that don't have a 'pyproject.toml' file. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/11451
Running setup.py install for pycurl ... error
error: subprocess-exited-with-error
× Running setup.py install for pycurl did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
Using curl-config (libcurl 7.79.1)
Using SSL library: OpenSSL/LibreSSL/BoringSSL
running install
/Users/thiennq/workspace/pet/nut/testnut/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-cpython-39
creating build/lib.macosx-12-arm64-cpython-39/curl
copying python/curl/__init__.py -> build/lib.macosx-12-arm64-cpython-39/curl
running build_ext
building 'pycurl' extension
creating build/temp.macosx-12-arm64-cpython-39
creating build/temp.macosx-12-arm64-cpython-39/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/docstrings.c -o build/temp.macosx-12-arm64-cpython-39/src/docstrings.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/easy.c -o build/temp.macosx-12-arm64-cpython-39/src/easy.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/easycb.c -o build/temp.macosx-12-arm64-cpython-39/src/easycb.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/easyinfo.c -o build/temp.macosx-12-arm64-cpython-39/src/easyinfo.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/easyopt.c -o build/temp.macosx-12-arm64-cpython-39/src/easyopt.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/easyperform.c -o build/temp.macosx-12-arm64-cpython-39/src/easyperform.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/module.c -o build/temp.macosx-12-arm64-cpython-39/src/module.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/multi.c -o build/temp.macosx-12-arm64-cpython-39/src/multi.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/oscompat.c -o build/temp.macosx-12-arm64-cpython-39/src/oscompat.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pythoncompat.c -o build/temp.macosx-12-arm64-cpython-39/src/pythoncompat.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/share.c -o build/temp.macosx-12-arm64-cpython-39/src/share.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/stringcompat.c -o build/temp.macosx-12-arm64-cpython-39/src/stringcompat.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/threadsupport.c -o build/temp.macosx-12-arm64-cpython-39/src/threadsupport.o
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I /opt/homebrew/opt/openssl@3/include -DPYCURL_VERSION=\"7.45.2\" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Users/thiennq/workspace/pet/nut/testnut/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/util.c -o build/temp.macosx-12-arm64-cpython-39/src/util.o
gcc -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -L /opt/homebrew/opt/openssl@3/lib -I /opt/homebrew/opt/openssl@3/include build/temp.macosx-12-arm64-cpython-39/src/docstrings.o build/temp.macosx-12-arm64-cpython-39/src/easy.o build/temp.macosx-12-arm64-cpython-39/src/easycb.o build/temp.macosx-12-arm64-cpython-39/src/easyinfo.o build/temp.macosx-12-arm64-cpython-39/src/easyopt.o build/temp.macosx-12-arm64-cpython-39/src/easyperform.o build/temp.macosx-12-arm64-cpython-39/src/module.o build/temp.macosx-12-arm64-cpython-39/src/multi.o build/temp.macosx-12-arm64-cpython-39/src/oscompat.o build/temp.macosx-12-arm64-cpython-39/src/pythoncompat.o build/temp.macosx-12-arm64-cpython-39/src/share.o build/temp.macosx-12-arm64-cpython-39/src/stringcompat.o build/temp.macosx-12-arm64-cpython-39/src/threadsupport.o build/temp.macosx-12-arm64-cpython-39/src/util.o -lssl3 -lssl -lcrypto -lcurl -o build/lib.macosx-12-arm64-cpython-39/pycurl.cpython-39-darwin.so -flat_namespace
ld: library not found for -lssl3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pycurl
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
did you run pip3 uninstall pycurl first?
try this pip3 uninstall pycurl --use-pep517
If you get the following error while running pip3 install --compile --install-option="--with-openssl" pycurl
:
(...)
src/pycurl.h:178:13: fatal error: 'openssl/ssl.h' file not found
# include <openssl/ssl.h>
^~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
this fixed it for me:
brew reinstall openssl
PYCURL_SSL_LIBRARY=openssl \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
CPPFLAGS="-I$(brew --prefix openssl)/include"
After this, try running the command again: pip3 install --compile --install-option="--with-openssl" pycurl
After that I keep getting this error:
QFactoryLoader::QFactoryLoader() checking directory path "/Users/marck/.pyenv/versions/3.9.13/bin/platforms" ...
objc[1083]: Class QMacAutoReleasePoolTracker is implemented in both /usr/local/Cellar/qt@5/5.15.8_2/lib/QtCore.framework/Versions/5/QtCore (0x106341a08) and /Users/marck/Documents/github/nut/testnut/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x11432f198). One of the two will be used. Which one is undefined.
objc[1083]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /usr/local/Cellar/qt@5/5.15.8_2/lib/QtCore.framework/Versions/5/QtCore (0x106341a80) and /Users/marck/Documents/github/nut/testnut/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x11432f210). One of the two will be used. Which one is undefined.
objc[1083]: Class KeyValueObserver is implemented in both /usr/local/Cellar/qt@5/5.15.8_2/lib/QtCore.framework/Versions/5/QtCore (0x106341aa8) and /Users/marck/Documents/github/nut/testnut/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x11432f238). One of the two will be used. Which one is undefined.
objc[1083]: Class RunLoopModeTracker is implemented in both /usr/local/Cellar/qt@5/5.15.8_2/lib/QtCore.framework/Versions/5/QtCore (0x106341af8) and /Users/marck/Documents/github/nut/testnut/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x11432f288). One of the two will be used. Which one is undefined.
loaded library "/Users/marck/Documents/github/nut/testnut/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqcocoa.dylib"
QObject::moveToThread: Current thread (0x600002d58070) is not the object's thread (0x600002d50800).
Cannot move to target thread (0x600002d58070)
You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
It looks like the Qt packages keep looking at two locations? I found this, but that discusses older versions. https://github.com/ronaldoussoren/py2app/issues/380
I think it is because at some point we copy the files to the venv, so I think it looks there and at the system files:
sudo cp -R /opt/homebrew/Cellar/pyqt@5/5.15.7_2/lib/python3.9/site-packages/* ./testvenv/lib/python3.9/site-packages
.
I removed that folder, but then I get 'module not found' errors.
I followed the above steps and also the README guide but I'm getting the following error when running nut.py or nut_gui.py
ImportError: cannot import name 'Title' from partially initialized module 'nut'
Is your feature request related to a problem? Please describe. after so many tries and errors of installation on my own macbook, would you please release macos cli and macos nut-gui for download
Describe the solution you'd like download macos nut cli and nut gui from release page
Describe alternatives you've considered A description of any alternative solutions or features you've considered.