QtCreator Python.h with Anaconda Python - python

Trying to embed anaconda Python into a Qt application. As a first step, I just want to get Python.h including properly.
I am running Qt4, Python 2.7.9, and OS X 10.9.
The project.pro has:
INCLUDEPATH += /home/myuser/anaconda/include/python2.7 /home/myuser/anaconda/include
LIBS += -L/home/myuser/anaconda/lib/python2.7 -lpython2.7
appended to the end.
In spite of this, I am getting the system installed python 2.7.5. This is verified by running import sys, sys.version and sys.path.
Clearly, I am missing something - a compiler flag? New to QtCreator, so any insight appreciated.

Related

Getting an old python script that needs gtk to work

So I'm trying to fix up an old program and I've been trying to run its main script on my Mac, but it says it can't find module gtk (it says it's a required dependency in the README). I have tried a ton of things to get this script to run, I've installed both python 2 and 3 with brew, installed many versions of pygtk with brew, tried to run the script on my user dir and in a python 2 and 3 virtualenv, added #!/usr/bin/env python2 and added a sys path to where brew installed pygtk, but all to no avail. Neither gtk nor pygtk can seem to be found. My original attempt at using pip to install pygtk resulted in this output:
Complete output from command python setup.py egg_info:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file. *
********************************************************************
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
/private/var/folders/6l/k1kfh5415ln0886zznkffpr80000gn/T/pip-install-
50TCjw/pygtk/
So... my question is: how should I proceed? I'm actually not sure what gtk does. Should I attempt to update this program to python3 compatibility? What is the state of compatibility for gtk? And how can I check if I actually even have gtk on my system? Because homebrew is pretty convinced that I do.
Update:
So I manually used the python2.7 that was installed via brew (in usr/local/Cellar/python#2) and this seemed to fix the gtk problem. However now it can't import webkit module which is somewhere else in the program, and I'm stuck here now...
Finally got all the dependancies loaded. python-webkit was apparently completely deprecated, I had to find the last macOS compatible version of it at https://code.google.com/archive/p/pywebkitgtk/downloads and then it was a simple matter of running its configure file and adding its install location to my Cellar python#2 program's sys path. Now the rest of the program is pretty messed up but I accomplished what I wanted for now

Pyinstaller executable fails on old OS X

I have a wxPython GUI packaged into an executable with Pyinstaller. It works correctly on OS X 10.13.4, but doesn't initialize on OS X 10.12.6.
This is the error output when my executable is run from the command line:
[4693] Error loading Python lib '/var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python': dlopen: dlopen(/var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python, 10): Symbol not found: _futimens
Referenced from: /var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libSystem.B.dylib
in /var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python
I have no idea what this error message means. I've tried googling some pieces of it, but I'm not getting any meaningful results.
I'm looking for any clue to get me going in the right direction -- what might be wrong, or how to debug. Unfortunately I don't have access to OS X 10.12.6, so I'm having to troubleshoot for a user remotely.
This is my version of Pyinstaller:
pyinstaller 3.4.dev0+g07ab024c
This seems to happen with brew-installed Python or Anaconda.
A bit late, but it has happened to me as well. After a bit of research, as per the documentation:
https://pyinstaller.readthedocs.io/en/stable/usage.html#making-mac-os-x-apps-forward-compatible
Basically you'll need to install a virtual machine with the oldest OS you'd like support (say, osx maverick, or ubuntu 16) with the complete development environment and run pyinstaller there. As of the time of writing, there seems to be no way around it.

clang.cindex.LibclangError "Undefined symbol clang_CXXRecord_isAbstract"

I am trying to execute clang 5.0 with the next commands but it does not work.. I typed:
import clang
import clang.cindex
clang.cindex.Config.set_library_file('/usr/lib/x86_64-linux-gnu/libclang-5.0.so.1')
id = clang.cindex.Index.create()
and I received the following error:
clang.cindex.LibclangError: /usr/lib/x86_64-linux-gnu/libclang-5.0.so.1: undefined symbol: clang_CXXRecord_isAbstract. Please ensure that your python bindings are compatible with your libclang.so version.
I am using clang-5.0 with the bindings from https://github.com/llvm-mirror/clang
Windows
I haven't tested this right now, but it worked a month ago for me.
Either download the src code from github and go to /bindings/python/ and copy the clang directory and paste it into your python site packages dir or (try both) pip install clang-5
Download the llvm binares. If you have python-32bit then install llvm 32bit!! Otherwise it wont work. For 64bit python install the 64bit binaries
In your python program just import clang.cindex as cl and in your code do cl.Config.set_library_file("your/path/to/libclang.dll")
libclang.dll should be in your clang/bin installation directory
Linux
Running it right now, so it works for me
pip3 install clang-5
from your package manager either get llvm-clang or llvm-clang-32bit
depending on your python installation
In your python program just import clang.cindex as cl and in your code do cl.Config.set_library_file("your/path/to/libclang.so")
From my experience libclang.so should be located in either /usr/lib32/ or usr/lib64/
Hope this helps!

Error in using PyQt4 with python 3.5.2 for running a PyMoskito example

I'm trying to get an example of PyMoskito running under Python 3.5.2 Win7 64 bit
This library needs PyQt4 which in turn needs SIP.
1- I installed SIP using pip3 install SIP which ended up successfully (with a notice to update my pip).
2- I even barely know Python. So I tried installing PyQt4 with a binary executable. The binaries provided at riverbankcomputing.com/software/pyqt/download are for python 3.4 so I downloaded an unofficial wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4 with a name PyQt4-4.11.4-cp35-none-win_amd64.whl. Then I cd'ed into the respective directory and installed it with pip which ended up successfully.
Now, I don't know what is the standard procedure for testing if a library is working. So I ran setup.py from the main directory of library and I assumed it set things up. Then I ran an example from examples folder and I get this error
Traceback (most recent call last):
File "C:\Users\****\Documents\Python Libraries\pymoskito-master\pymoskito-master\examples\ballbeam\main.py", line 3, in <module>
from PyQt4 import QtGui, QtCore
ImportError: DLL load failed: The specified module could not be found.
I assume python could NOT find the PyQt4 dependencies. I searched stackoverflow and non of the solutions worked. Here is what I tried so far:
There is NO /bin directory in C:\Python35\Lib\site-packages\PyQt4. So all dlls are already in the \PyQt4 directory
I added this directory to System PATH env. var. Same error occurs
I appended this directory to sys.path and tested it. Same error occurs
I created a \bin directory and copied all \PyQt4 into it. Then added it to PATH. Same error occurs
After that, I installed python 2.7 and PyQt4 from riverbankcomputing but not SIP. I still have the same problem
I really don't know what else should I do. I'm actually frustrated by all the mentioning of whether OP is using Python 2 or Python 3 or QT4 or QT5 or x86 or x64. I believe backward compatibility should be the minimum of a programming language and this is definitely a mess for Python
The short answer, I believe is that you have pyqt4 (a python interface to the qt4 library), sip (an automated c++-to-python communication library) but not qt4 itself (the UI library). qt4 is it's own monolithic c++ project with its own build and dependency problems.
You may be able to find the various pieces at http://www.lfd.uci.edu/~gohlke , but I would recommend installing the Anaconda distribution of python ( https://www.continuum.io/downloads ), which provides binary packages for things like qt4 and pyqtgraph, the former of which is installed by default, the latter requiring a command like
conda install pyqtgraph
After this, pip install of pymoskito should work.
There is also mention in the readme of vtk, but it is not in the requirememnts. vtk is also a monolithic c++ library and hard to build, but conda has that too, albeit not in the default channel for py35:
conda install vtk -c menpo

Import scip to python

I've tried unsuccessfully to get scip running with python. I'm using Yosemite (10.10.3), python 2.7 and have installed scip optimization suit (http://scip.zib.de/download.php?fname=scipoptsuite-3.1.1.tgz) with make.
I can start scip after the installation via the terminal.
sages-MBP:~ sage$ scip SCIP version 3.1.1 [precision: 8 byte] [memory: block] >[mode:optimized][LP solver: SoPlex 2.0.1] [GitHash: bade511]
But when I try to use import scip in python there appears the message
No module named scip
The same error message appears for from zibopt import scip
If I print the system path with print sys.path in python, the folder scipoptsuite-3.1.1/scip-3.1.1/bin is included where the file
scip-3.1.1.darwin.x86_64.gnu.opt.spx is situated.
Is it possible that the reason for the error message is that I haven't linked correctly necessary libraries?
Or which folders have to be included in the pythonpath to get scip working?
I Hope someone can help me out!
You need to install the python interface that comes with SCIP. Go to scip/interfaces/python/ and read the instructions in README and INSTALL. This interface is using Cython to communicate with the C-Code of SCIP.
make will only install the native Linux or Mac binaries/libraries.
The environment variable DYLD_LIBRARY_PATH needs to be set to contain the lib/ directory of the SCIPoptSuite installation (see comment by #саша)

Categories