PyQt5 Modules not Found? - pyqt5

This is a complete fresh install of MacOS!
Platform:
Apple MacBook Air - M1
MacOS Monterey
Package Info:
Homebrew: 3.3.14
pip: 22.0.3
Python: 3.9.10 (installed via 'brew install python')
Latest-Xcode
My $PATH environment:
/opt/homebrew/bin
/opt/homebrew/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
I tried adding a combination of these to my $PATH, to no avail:
/opt/homebrew/lib/python3.9/site-packages
/opt/homebrew/Cellar/pyqt#5/5.15.6/lib/python3.9/site-packages/PyQt5
/opt/homebrew/lib/python3.9/site-packages/PyQt5
/opt/homebrew/opt/pyqt#5/5.15.6/bin
/opt/homebrew/opt/qt#5/5.15.6/bin
What I want to do:
pip install pyqt5
What happens when I try:
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 83, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sipbuild/project.py", line 594, in setup
self.apply_user_defaults(tool)
File "project.py", line 63, in apply_user_defaults
super().apply_user_defaults(tool)
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sipbuild/project.py", line 241, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
If I install it this way, I get no errors:
brew install pyqt#5
But my VS Code shows up like this, and none of submodules work:
My program used to work just fine, but I had recently installed Python 3.10 and have since uninstalled it. Ever since the new Python install, I've had this issue. Not sure how to tackle this. Thank you!

I've asked this question a number of different ways in a number of different places; none of the suggested answers work for me.
The closest thing to an answer that I got to was this:
https://www.zhihu.com/question/437075754/answer/1993415429
If you're unable to read it, it suggests this:
Pre-work, install homebrew, python 3.9.
First enter in the terminal:
brew install pyqt5
echo 'export PATH="/opt/homebrew/opt/qt#5/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/pyqt#5/5.15.4_1/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Then, copy all the contents of
/opt/homebrew/Cellar/pyqt#5/5.15.4_1/lib/python3.9/site-packages to
lib/python3.9/site-packages folder. If your homebrew installation
address and python installation address are not the default, you need
to modify these two addresses.
Finally, try it in python
import PyQt5
But this didn't work for me, either.
In the end, I ended up just installing PyQt6:
pip install PyQt6
The install completed without any errors. Now I am working on updating my code. Hopefully this will be useful for someone else coming here from an angry Google search. Code on, my friends.

I had the issue as yours. I solve with the following command.
pip3 install pyqt5

my install setup is
1.brew install qt
2.brew install libxml2
reference by TheCrazySwede answer ↓↓↓
3.brew install pyqt5
enter image description here
4.brew cleanup pyqt#5
5.echo 'export PATH="/opt/homebrew/opt/qt#5/bin:$PATH"' >> ~/.zshrc
6.echo 'export PATH="/opt/homebrew/opt/pyqt#5/5.15.4_1/bin:$PATH"' >> ~/.zshrc
7.source ~/.zshrc
8.pip3 install pyqt5-sip
9.pip3 install pyqt5
enter image description here
enter image description here
10.pip3 install lxml
11.make qt5py3
I hope can help for you.

Related

Tensorflow docker installation problem. (undefined symbol: _ZN10tensorflow8OpKernel11TraceStringEPNS_15OpKernelContextEb)

I am trying to learn more about tensorflow and building a custom model with it.
I follow an instruction in which i install a docker container with the following steps:
git clone https://github.com/tensorflow/models.git
cd models
docker build -f research/object_detection/dockerfiles/tf2/Dockerfile -t od .
docker run -it od
All works ok.
Next step is to run a test in the container script:
python object_detection/builders/model_builder_tf2_test.py
This fails and outputs:
Traceback (most recent call last):
File "object_detection/builders/model_builder_tf2_test.py", line 22, in <module>
import tensorflow.compat.v1 as tf
File "/home/tensorflow/.local/lib/python3.6/site-packages/tensorflow/__init__.py", line 438, in <module>
_ll.load_library(_main_dir)
File "/home/tensorflow/.local/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 154, in load_library
py_tf.TF_LoadLibrary(lib)
tensorflow.python.framework.errors_impl.NotFoundError: /usr/local/lib/python3.6/dist-packages/tensorflow/core/kernels/libtfkernel_sobol_op.so: undefined symbol: _ZN10tensorflow8OpKernel11TraceStringEPNS_15OpKernelContextEb
So there is a question about this in stackoverflow see:
Also a followup at:
It says, if i understand correctly, to uninstall and install tensorflow again, but it does not work.
The version is 2.6.1. If i try to downgrade i run into all kind of other problems.
I am stuck ;-(, any clues ?
I am working on a VPS, is it possible to run the tensorflow docker on 'normal' hardware ?

gn scripts are run with the wrong Python version ("a bytes-like object is required, not 'str'")

When building Chromium or libwebrtc with gn on macOS (Catalina 10.15), I get errors from the Python build scripts about bytes and str. For example:
src [heads/master●] % gn gen out/ios_64 --args='target_os="ios" target_cpu="arm64"'
ERROR at //build/config/ios/ios_sdk.gni:109:21: Script returned non-zero exit code.
_ios_sdk_result = exec_script(script_name, ios_sdk_info_args, "scope")
^----------
Current dir: /Users/lynn/code/webrtc_ios/src/out/ios_64/
Command: python /Users/lynn/code/webrtc_ios/src/build/config/mac/sdk_info.py --get_sdk_info iphoneos
Returned 1.
stderr:
Traceback (most recent call last):
File "/Users/lynn/code/webrtc_ios/src/build/config/mac/sdk_info.py", line 107, in <module>
FillXcodeVersion(settings, args.developer_dir)
File "/Users/lynn/code/webrtc_ios/src/build/config/mac/sdk_info.py", line 59, in FillXcodeVersion
settings['xcode_version'] = FormatVersion(lines[0].split()[-1])
File "/Users/lynn/code/webrtc_ios/src/build/config/mac/sdk_info.py", line 43, in FormatVersion
major, minor, patch = SplitVersion(version)
File "/Users/lynn/code/webrtc_ios/src/build/config/mac/sdk_info.py", line 30, in SplitVersion
version = version.split('.')
TypeError: a bytes-like object is required, not 'str'
See //build/config/sysroot.gni:67:3: whence it was imported.
import("//build/config/ios/ios_sdk.gni")
^--------------------------------------
See //build/config/linux/pkg_config.gni:5:1: whence it was imported.
import("//build/config/sysroot.gni")
^----------------------------------
See //BUILD.gn:15:1: whence it was imported.
import("//build/config/linux/pkg_config.gni")
^-------------------------------------------
When I edit the offending Python script to print(sys.version), it shows that it is running Python 3, even though the scripts are supposed to running with the bundled virtual Python 2.7 environment defined in .vpython.
How do I configure gn to run these scripts with the appropriate Python version?
It seems exec_script is running these scripts with the machine Python version. gn help exec_script says:
The default script interpreter is Python ("python" on POSIX, "python.exe" or
"python.bat" on Windows). This can be configured by the script_executable
variable, see "gn help dotfile".
For me, python points to Python 3. So I had to add this line to the end of the .gn dotfile:
script_executable = "vpython"
Now the build uses the virtual Python defined in .vpython, which is Python 2.7.
(The vpython executable is provided by Chromium depot_tools, just like gn.)

Orange Error During Installing Text Add On

I am trying to install the Text add-on (version 0.7.3) for Orange (version 3.23) on my Win10, but I am getting the following error during the building "ufal_udpipe":
Command failed: python python -m pip install --constraint 'C:\Users\Jakub\AppData\Local\Temp\tmpb4fneogu.txt' Orange3-Text exited with non zero status.
ERROR: Command errored out with exit status 1: 'C:\Users\Jakub\AppData\Local\Orange\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jakub\\AppData\\Local\\Temp\\pip-install-r71cit89\\ufal.udpipe\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jakub\\AppData\\Local\\Temp\\pip-install-r71cit89\\ufal.udpipe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Jakub\AppData\Local\Temp\pip-record-gtt8e801\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
I also tried to install Microsoft Visual C++, because it´s required in the log, but the problem is the same after the installation.
I tried to install add-on throught the Anaconda Prompt:
conda config --add channels conda-forge
conda install orange3-text
This process failed, because:
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::commonmark-0.9.0-py_0'.
CondaError: Cannot link a source that does not exist. C:\Users\Jakub\Miniconda3\Scripts\conda.exe
Running `conda clean --packages` may resolve your problem.
Attempting to roll back.
Rolling back transaction: done
The result of conda clean command is following:
Traceback (most recent call last):
File "C:\Users\Jakub\Miniconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\cli\main.py", line 112, in main
from ..exceptions import conda_exception_handler
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\exceptions.py", line 18, in <module>
from .common.io import timeout
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\common\io.py", line 28, in <module>
from .._vendor.tqdm import tqdm
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\__init__.py", line 8, in <module>
from ._tqdm import tqdm
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\_tqdm.py", line 13, in <module>
from ._utils import _supports_unicode, _environ_cols_wrapper, _range, _unich, \
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\_utils.py", line 31, in <module>
colorama.init()
AttributeError: module 'colorama' has no attribute 'init'
Reinstall of Orange and Anaconda didn´t help.
Full extract of logs is here: Google Disk
Thank you for your help!
Jakub
I encountered just the first line of your error. I checked if I had python and anaconda installed properly or not (and I had). I then kept trying to install and in the 4th go it installed without an issue- now my guess is maybe network issues caused the error to occur.
Another thing suggested to me by their support was- "Yes, we are aware of the issue. Somewhere in the process we accidentally disabled the necessary setting. Go to Options - Settings, find the Add-ons tab and select 'Install add-ons with conda'. This should install Text successfully."
Okay, so I found the issue fix (at least for me - comment if it works for you).
How to fix it:
Download Colorama
Copy the "Colorama" from the download then replace the folder named "colorama" in C:\Program Files\Anaconda3\Lib\site-packages
I suspect this issue occurs because of (issue 8842)

ModuleNotFoundError: No module named 'tensorflow.contrib.lite.toco.python'

Exact command to reproduce: toco --help
I am trying to run the codelab tutorial of tensorflow lite. After installing tf-nightly, when I try to run the command "toco --help", I get the error ModuleNotFoundError: No module named 'tensorflow.contrib.lite.toco.python'.
I have tried this on 3 computers( all Windows) and the same problem persists.
Source code / logs
C:\Users\HP\Downloads>toco --help
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in
_run_module_as_main "main", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\toco.exe_main.py", line 5, in 
ModuleNotFoundError: No module named
'tensorflow.contrib.lite.toco.python'
I was getting the same error and apparently TOCO doesn't work on Windows machines,
https://github.com/tensorflow/tensorflow/issues/16374
My alternative to optimize the model was to user TensorFlow Mobile, instead of TensorFlow Lite, and use 'optimize_for_inference'. You could also try on a linux environment.
I solved it by downgrading tensorflow to 1.7
pip install --upgrade "tensorflow==1.7.*"
Issue Solved
Clone the tensorflow repository an copy the lite folder from tensorflow\tensorflow\contrib
and paste it in the C:\Users\$USERNAME$\AppData\Local\Programs\Python\Python36\Lib\site-packages\tensorflow\contrib\lite
The tensorflow library in Python36 has some missing files. My Python36 folder is in c:\Python36. So the toco will load "C:\Python36\Lib\site-packages\tensorflow\contrib\lite\python". Whoever coded the toco forgot to copy the whole folder into there.
You need to copy from your tensorflow folder to the lite folder. My tensorflow is at
"c:\tensorflow". The lite folder looks like this:
Copy all files from "C:\tensorflow\tensorflow\contrib\lite\python" to "C:\Python36\Lib\site-packages\tensorflow\contrib\lite\python".
Now, you need to make a test, "toco --help"

Install NumPy for Python 3.2.3 on OS X 10.7.4

I have been trying for months to get numpy installed for Python 3 but despite copious amounts of Googling and even posting to the numpy mailing list I am still no closer to a solution.
I have managed to get it installed via MacPorts but unfortunately there doesn't appear to be a port of MatPlotLib for Python 3 which is the main reason I am trying to install numpy...so I am a bit stuck...
I keep getting the same error whilst trying to build from the setup.py file. I have included the terminal output below.
Thanks for any help you can offer,
Adam.
Here is the terminal output:
lipo: can't figure out the architecture type of: /var/folders/zj/7xymy_2n3s71ws30v3v_qnlw0000gn/T//ccbRr0Hj.out
failure.
removing: _configtest.c _configtest.o
Running from numpy source directory.Traceback (most recent call last):
File "setup.py", line 214, in <module>
setup_package()
File "setup.py", line 207, in setup_package
configuration=configuration )
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/core.py", line 186, in setup
return old_setup(**new_attr)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build.py", line 37, in run
old_build.run(self)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 152, in run
self.build_sources()
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 169, in build_sources
self.build_extension_sources(ext)
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 328, in build_extension_sources
sources = self.generate_sources(sources, ext)
File "/Users/adammcnicol/Downloads/numpy-1.6.2rc1/build/py3k/numpy/distutils/command/build_src.py", line 385, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 410, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 41, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 271, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
Well, I finally managed to get NumPy to install. Not sure it is the best method but it seems to work!
First of all i needed to install distribute:
curl http://python-distribute.org/distribute_setup.py | python3
Then I installed pip:
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python3
After that I had to get pip on to my system path (again there are probably better ways):
Open Terminal
Type the following (single line):
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.2/bin/pip /usr/local/bin
With distribute and pip installed I then installed Nose, which NumPy needs for testing or something:
Again, in Terminal type the following:
pip install nose
Now I needed to make sure I had the latest version of Xcode:
From the AppStore install the latest version of Xcode
If you still have a /Developer folder then rename it Developer-old (not sure whether this will cause problems for me later or not)
Open Terminal and create a symlink to the AppStore version of Xcode (single line):
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer
With all of that out of the way time to install NumPy:
Download the NumPy source from: http://sourceforge.net/projects/numpy/files/NumPy/1.6.2rc1/
Unarchive the file
Open Terminal again:
cd into the directory created by unarchiving the file e.g.
cd /Users/username/Downloads/numpy-1.6.2rc1
Type into the Terminal the following to change the complier used to build NumPy:
export CC=clang
export CXX=clang
export FFLAGS=-ff2c
export LDSHARED='clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -g' (this is a single line)
python3 setup.py build (this may take a while)
python3 setup.py install
Okay, assuming there were no errors NumPy should be installed. Time to test it out:
Open IDLE
In the Python Shell type:
import numpy
numpy.test('full')
This will test NumPy the final result I received with Python 3.2.3 was:
<nose.result.TextTestResult run=3192 errors=0 failures=1>
So the NumPy installation passes all except one test, which seems pretty good. I haven't had a chance to see if works properly yet as I am still struggling to get matplotlib installed...
Hope these instructions are useful to somebody!
Adam.
I'm using Python 3.3 and OS X 10.7, and I installed numpy using a much easier method than above. I'm posting here in case it can help someone.
Follow these steps:
Download the zip file from numpy on github, and unpack it wherever you want.
Open a terminal and cd to the directory
enter the command python3 setup.py build --fcompiler=gnu95 (requires gfortran. Enter gfortran -v to see if you've got it, I've got version 4.6.2)
enter python3 setup.py install
That's all it took for me. Running numpy.test('full') gives me some errors, however: http://pastebin.com/5XF0qAe5
I don't know what kind of errors I'm going to experience yet.
The above answer worked great for me, except that you mentioned this was for OS X 10.7 (same here) so my build command did complain about the line:
export LDSHARED='clang -bundle -undefined dynamic_lookup -arch i386
-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -g' (this is a single line)
So, I just changed that to 10.7 and it worked fine. Apparently, for OS X 10.7, the /Developer/SDKs/ directory contains MacOSX10.7.sdk and MacOSX10.8.sdk. Thanks for the great answer!
I've come back to this answer a number of times, if you're using 10.8, you need to do a few things to get this to work (but I don't think you need the LDSHARED part).
Install XCode from Apple as well as the command line tools (this gets you the compilers you need).
set environment variables to point to clang and use easy_install (NOT distribute) to install, this line will work:
CC=clang CXX=clang FFLAGS=-ff2c easy_install numpy
Do not try to install other packages at the same time. The numpy install may exit claiming an error, but often it manages to install itself anyways (for example, if you try to install in a virtualenv, this may happen).
for me i installed python3 from their website and then to install numpy,
pip3 install numpy
it works!