PyQT error: building Mac cfclient

Post here to get support
Post Reply
memelab
Beginner
Posts: 6
Joined: Thu Nov 07, 2013 11:07 pm

PyQT error: building Mac cfclient

Post by memelab »

Trying to build cfclient-2016.4.1 on
- MacOS: Mavericks 10.9.5

Have followed all instructions but when I run

/usr/local/bin/python3 /usr/local/bin/cfclient

I get:

INFO:cfclient.gui:Disabling STL printouts
INFO:cfclient.gui:Foundation not found. Menu will show python as application name
Traceback (most recent call last):
File "bin/cfclient", line 9, in <module>
load_entry_point('cfclient', 'console_scripts', 'cfclient')()
File "/Users/george/Documents/crazyflie/cfclient/cfclient-2016.4.1/src/cfclient/gui.py", line 135, in main
from .ui.main import MainUI
File "/Users/george/Documents/crazyflie/cfclient/cfclient-2016.4.1/src/cfclient/ui/main.py", line 33, in <module>
import cfclient.ui.tabs
File "/Users/george/Documents/crazyflie/cfclient/cfclient-2016.4.1/src/cfclient/ui/tabs/__init__.py", line 33, in <module>
from .ConsoleTab import ConsoleTab
File "/Users/george/Documents/crazyflie/cfclient/cfclient-2016.4.1/src/cfclient/ui/tabs/ConsoleTab.py", line 35, in <module>
from PyQt4.QtCore import pyqtSignal
ImportError: No module named 'PyQt4.QtCore'

I used homebrew to install python3, pyqt --with-python3 and all other dependencies.

In /usr/local/lib/python3.5/site-packages/ I have a PyQt4 directory.

~/.bashrc has: export PYTHONPATH=/usr/local/lib/python3.5/site-packages
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: PyQT error: building Mac cfclient

Post by arnaud »

Hi,

As you suspected it looks like pyqt4 is not properly installed which is strange since you see it in the package folder. If you run python from the console can you import PyQt4:

Code: Select all

$ python3
Python 3.5.0 (default, Sep 23 2015, 04:42:00) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> 
If there is no error (like in my case) PyQT should be installed properly.

How did you install the client?
memelab
Beginner
Posts: 6
Joined: Thu Nov 07, 2013 11:07 pm

Re: PyQT error: building Mac cfclient

Post by memelab »

Thanks. I tried your suggestion and PyQt4 seems to be found:

Georges-MacBook-Air:~ georgemandella$ python3
Python 3.5.2 (default, Jun 29 2016, 13:42:46)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>>

So that's encouraging . . .

I had installed pyqt as directed in the README using homebrew:

brew uninstall pyqt
brew install pyqt --with-python3

It took more than 15 minutes, but it seemed to install OK. Perhaps the problem is in the cfclient code itself?

Thanks,
George
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: PyQT error: building Mac cfclient

Post by arnaud »

I meant how did you install the client?

The version 2016.4.1 has been pushed to the pypi repos which means that it is possible to install it with pip directly. Since cfclient is in /usr/local/bin I assume you installed it with "pip install cfclient"? Do you get the same error if you execute directly "cfclient" or "/usr/local/bin/cfclient"?
memelab
Beginner
Posts: 6
Joined: Thu Nov 07, 2013 11:07 pm

Re: PyQT error: building Mac cfclient

Post by memelab »

Sorry. to install the client, I ran the following from the top level of the source distribution (the directory that contains setup.py, etc.)

$ which pip3
/usr/local/bin/pip3

$ pip3 install -e .
Obtaining file:///Users/georgemandella/Documents/personal/electronics/crazyflie/downloads/cfclient/cfclient-2016.4.1
Requirement already satisfied (use --upgrade to upgrade): pysdl2 in /usr/local/lib/python3.5/site-packages (from cfclient==2016.4.1)
Requirement already satisfied (use --upgrade to upgrade): cflib==0.1.0 in /usr/local/lib/python3.5/site-packages (from cfclient==2016.4.1)
Requirement already satisfied (use --upgrade to upgrade): appdirs==1.4.0 in /usr/local/lib/python3.5/site-packages (from cfclient==2016.4.1)
Requirement already satisfied (use --upgrade to upgrade): pyzmq in /usr/local/lib/python3.5/site-packages (from cfclient==2016.4.1)
Requirement already satisfied (use --upgrade to upgrade): pyusb>=1.0.0b2 in /usr/local/lib/python3.5/site-packages (from cflib==0.1.0->cfclient==2016.4.1)
Installing collected packages: cfclient
Running setup.py develop for cfclient
Successfully installed cfclient-2016.4.1

NOTE: using pip3, not pip (as directed by README)
NOTE: this installs to /usr/local/bin/cfclient; it does not install anywhere local to this package.

If I run:
$ pip3 install cfclient
It generates the "Requirements already satisfied" messages, but does not output anything about "Installing collected packages"

Am I installing it the wrong way?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: PyQT error: building Mac cfclient

Post by arnaud »

No this should actually work, you are installing it from source (ie. it will run it from within the source directory). It is how we develop the client and it works.

I am currently upgrading brew on a mac to try to see if something broke in the latest pyqt package ...

To get the same version as you, from pip, I ran:

Code: Select all

$ pip3 uninstall cfclient
$ pip3 install cfclient    # This install 2016.4.1 from the pypi repos
And the /usr/lib/bin/cfclient file is starting with:

Code: Select all

#!/usr/local/opt/python3/bin/python3.5
Which is the brew python installation. If you try the same procedure are you seeing the same? Does it help?
memelab
Beginner
Posts: 6
Joined: Thu Nov 07, 2013 11:07 pm

Re: PyQT error: building Mac cfclient

Post by memelab »

$ pip3 uninstall cfclient
Uninstalling cfclient-2016.4.1:
/usr/local/lib/python3.5/site-packages/cfclient.egg-link
Proceed (y/n)? y
Successfully uninstalled cfclient-2016.4.1
$ ls /usr/local/bin/cfclient
ls: /usr/local/bin/cfclient: No such file or directory
$ pip3 install cfclient
Collecting cfclient
Downloading cfclient-2016.4.1.tar.gz (99kB)
100% |████████████████████████████████| 102kB 2.8MB/s
Requirement already satisfied (use --upgrade to upgrade): pysdl2 in /usr/local/lib/python3.5/site-packages (from cfclient)
Requirement already satisfied (use --upgrade to upgrade): cflib==0.1.0 in /usr/local/lib/python3.5/site-packages (from cfclient)
Requirement already satisfied (use --upgrade to upgrade): appdirs==1.4.0 in /usr/local/lib/python3.5/site-packages (from cfclient)
Requirement already satisfied (use --upgrade to upgrade): pyzmq in /usr/local/lib/python3.5/site-packages (from cfclient)
Requirement already satisfied (use --upgrade to upgrade): pyusb>=1.0.0b2 in /usr/local/lib/python3.5/site-packages (from cflib==0.1.0->cfclient)
Building wheels for collected packages: cfclient
Running setup.py bdist_wheel for cfclient ... done
Stored in directory: /Users/georgemandella/Library/Caches/pip/wheels/3c/08/ff/92e688c889c5a5570b29095adae8bad974c27c69de35559e92
Successfully built cfclient
Installing collected packages: cfclient
Successfully installed cfclient-2016.4.1
$ ls -l /usr/local/bin/cfclient
-rwxr-xr-x 1 georgemandella admin 234 Jul 20 14:48 /usr/local/bin/cfclient
$ cat /usr/local/bin/cfclient
#!/usr/local/opt/python3/bin/python3.5

# -*- coding: utf-8 -*-
import re
import sys

from cfclient.gui import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

----
However:
$ python3 /usr/local/bin/cfclient

still returns the same error as reported in first post.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: PyQT error: building Mac cfclient

Post by arnaud »

This is very strange, I updated my brew package and it is still working fine for me. I have MacOS 10.11.6 though (just upgraded as well).

There seems to be a problem in the pyqt installation. You can check that you have similar output for brew info sip and pyqt:

Code: Select all

$ brew info sip
sip: stable 4.18 (bottled), HEAD
Tool to create Python bindings for C and C++ libraries
https://www.riverbankcomputing.com/software/sip/intro
/usr/local/Cellar/sip/4.16.3 (9 files, 600.4K)
  Poured from bottle on 2014-10-26 at 14:47:23
/usr/local/Cellar/sip/4.16.9 (14 files, 1.1M)
  Built from source on 2016-02-27 at 14:50:24 with: --with-python3
/usr/local/Cellar/sip/4.18 (15 files, 1M) *
  Built from source on 2016-07-21 at 09:24:40 with: --with-python3
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/sip.rb
==> Options
--with-python3
	Build with python3 support
--without-python
	Build without python2 support
--HEAD
	Install HEAD version
==> Caveats
The sip-dir for Python is /usr/local/share/sip.

$ brew info pyqt
pyqt: stable 4.11.4 (bottled)
Python bindings for Qt
https://www.riverbankcomputing.com/software/pyqt/intro
/usr/local/Cellar/pyqt/4.11.4 (619 files, 33.1M) *
  Built from source on 2016-02-27 at 15:07:35 with: --with-python3
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pyqt.rb
==> Dependencies
Required: qt ✔, sip ✔
==> Options
--with-python3
	Build with python3 support
--without-python
	Build without python 2 support
==> Caveats
Phonon support is broken.
Maybe uninstalling and reinstalling sip and pyqt with the --with-python3 could help.
memelab
Beginner
Posts: 6
Joined: Thu Nov 07, 2013 11:07 pm

Re: PyQT error: building Mac cfclient

Post by memelab »

My packages look substantially the same. Output below in case I've missed something. However . . . can you please advise on the message after the Caveats for both of these. It makes a reference to the Python.sys path, but specifically for Python 2.7, and I know we need to be synced up with python 3.5. Perhaps there's a clue there?

$ brew info sip
sip: stable 4.18 (bottled), HEAD
Tool to create Python bindings for C and C++ libraries
https://www.riverbankcomputing.com/software/sip/intro
/usr/local/Cellar/sip/4.18 (15 files, 1M) *
Built from source on 2016-07-17 at 07:55:46 with: --with-python3
From: https://github.com/Homebrew/homebrew-co ... ula/sip.rb
==> Options
--with-python3
Build with python3 support
--without-python
Build without python2 support
--HEAD
Install HEAD version
==> Caveats
The sip-dir for Python is /usr/local/share/sip.

Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/georgemandella/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/georgemandella/Library/Python/2.7/lib/python/site-packages/homebrew.pth

$ brew info pyqt
pyqt: stable 4.11.4 (bottled)
Python bindings for Qt
https://www.riverbankcomputing.com/software/pyqt/intro
/usr/local/Cellar/pyqt/4.11.4 (619 files, 32.7M)
Built from source on 2016-07-17 at 07:26:24 with: --with-python3
From: https://github.com/Homebrew/homebrew-co ... la/pyqt.rb
==> Dependencies
Required: qt ✔, sip ✔
==> Options
--with-python3
Build with python3 support
--without-python
Build without python 2 support
==> Caveats
Phonon support is broken.

Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/georgemandella/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/georgemandella/Library/Python/2.7/lib/python/site-packages/homebrew.pth
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: PyQT error: building Mac cfclient

Post by arnaud »

The message seems to be for python2.7 so I am not sure it applies here, unless it has not been updated for python3.5.

I have no idea why it is not working for you as I never had this problem (it is working here so this is the hardest kind of problem to debug...).

Have you tried to uninstall/reinstall pyqt? Can you try on another machine/another partition? Your version of MacOS is quite old now so maybe there is a bug the brew package for this macos.
Post Reply