How to get MayaVi2 to default to/use Qt rather than wx? - enthought

Previously I have been using a python environment maintained by Mac ports. I had some basic scripts using PyQT, VTK, matplotlib etc. I have been able to use Paraview but seem a little heavy for my uses so I though I would try MayaVi2 (and TVTK).
I downloaded and tried to manually installing but it proved troublesome. So thought I would bite the bullet and try Canopy (academic License). Based on this VTK/Mayavi on Mac OS X which suggests all is good in the world of Qt, VTK and MayaVI, I installed 64 bit Canopy.
I am having trouble getting mayavi2 to work within the Canopy environment. It runs, but the console gets lots of errors, if I call up any dialog/setting box the "buttons" don't work properly. Here is the first error (of a couple of screen fulls) when I try to start mayavi2:
(Canopy 64bit) scratch_pad 501 $mayavi2 Traceback (most recent call
last): File
"/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/pyface/ui/wx/splash_screen.py",
line 121, in _on_paint
dc = wx.PaintDC(window)
I am actually more interested in TVTK, so I tried some of the mayavi demos from the website gallery http://docs.enthought.com/mayavi/mayavi/auto/examples.html The few I tried kind-a worked, that is they display a VTK (?) window/scene, I can interact with the VTK window. All is good until I open a settings/dialogue window, and then none of dialogue window "button" work and i have to force quit. Here is the last line of error when I open the "Setting" button in the plot3D demo:
simple demo: File
"/Users/michael/Library/Enthought/Canopy_64bit/System/lib/python2.7/site-packages/wx/_core.py",
line 9162, in DestroyChildren
return core.Window_DestroyChildren(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "GetEventHandler() == this"
failed at /BUILD/wxPython-src-2.9.2.4/src/common/wincmn.cpp(468) in
~wxWindowBase(): any pushed event handlers must have been removed
I even tried
ipython --gui=wx
(as suggested on the page) but in this case it crashes, no window.
Based on the error messages on the console they all appear to be wx related. It is my understanding the the Canopy environment is "self-contained", but could my old environment be somehow conflicting? How would I even test this?
Is there a way, environment variable, that mayavi2 can use Qt instead of wx? I don't use wx in any of my local python scripts, so unless it is needed in Canopy I am quite happy to disable, if that is an option.
Any ideas?

After running most of the examples in the Mayavi Gallery I have discovered that I needed to inform Traits to use Qt. This was done by setting an environment variable from within the script using a sys.environment() call. I decided to set the environment variable ETS_TOOLKIT to qt4 in my .profile as follows:**
export ETS_TOOLKIT=qt4
Mayavi2 now works as advertised!

Related

eclipse pydev debug source lookup

So I have anaconda installed and make a separate environment for all my projects. Normally I just use PYDEV to create a new interpreter pointing to the anaconda enviornment and load the project in eclipse and all is good. After doing the last one though 95% of the time I go to debug I keep getting the error
An internal error occurred during: "Debug Source Lookup".
java.lang.IllegalArgumentException
The other 5% it kind of works as I can follow one script or a function before it starts breaking.
I've tried reloading the project, interpreter and conda enviornment to no luck. All my past projects which use to work are also now giving the same error.
The funny thing is when I'm in the debug perspective though it does seem to be working (I can see the Variables and use the interactive console to test stuff), but anytime I try to step into, over ect I get the error (even though it does seem to be working). So for the image above I can go through the code fine until it tries to jump to the other file which throws the error, but if I step into it I can manually open that file and walk through the function (just each step throws the error) and still interact with the code which is in the position through the console.
Any ideas how to fix?
Well, it may be something specific to this use-case (for instance, if the code for some object is evaluated and the source code is not really available for the debugger this is actually expected).
Can you provide the full stacktrace from the error log? (see: http://www.pydev.org/faq.html#HowdoIReportaBUG for details on how to get it)

"Undefined variable: Environment" when editing SConscript file in Eclipse Neon

I have an SCons project (an implementation of the Generic Mapping Tools tutorial at http://gmt.soest.hawaii.edu/doc/latest/GMT_Tutorial.html using SCons rather than shell scripts), and I am using Eclipse Neon to edit the Sconstruct file.
The Sconstruct file starts in quite a standard way (the rest of the file is immaterial to this question).
import os
import collections
env = Environment(ENV = os.environ)
bld = Builder(action = 'ps2pdf $SOURCE $TARGET', \
suffix = '.pdf', \
src_suffix = '.ps')
What is annoying me is that while the build works perfectly using scons, Eclipse keeps marking the Environment and Builder constructions as "Undefined variables".
I installed the SConsolidator plugin, but it makes no difference.
I find the marking of an error that is not an error incredibly annoying.
While I could do something like tell Eclipse to ignore the error, I would prefer something more intelligent, such as adding Scons to the library path. I have tried adding C:\Python27\Lib\site-packages\scons-2.5.1\Scons and C:\Python27\Lib\site-packages\scons-2.5.1\Scons\Scripts to the Python Interpreter Paths (Window → Preferences → PyDev → Interpreters → Python Interpreters → Paths), and using an import directive like from SConscript.SCons import * but it doesn't make a difference.
Try library path:
C:\Python27\Lib\site-packages\scons-2.5.1\
Then
from SCons.Script import *
First thing first - if you know exactly where does your plugin keep it's symbol index(es) make sure that they don't get deleted by whatever the editor/IDE/build think they are doing to "be helpful".
Python plugins for editors easily get confused and you may need you to draw very explicit and detailed picture and train them a bit (by stopping the code in debugger) in order for a scanner/indexer to "wake up" and finally scan and index all symbols.
What I do in VS (with PTVS) is to make one proj for Scons_lib (home at C:\Python27\Lib\site-packages\scons-2.5.0), another for Scons_Scripts (C:\Python27\Scripts\, startup file: scons.py)
and then separate projects for separate scons driven folders/builds. To get editor to immediately recognize building files as Python I add extension .scons (google's convention used in Chrome build, Sconcsript's are ProjName.scons), tell VS that .scons is also Python, rename Sconstruct to Make.scons.
Then I run in debugger, (with -f Make.scons -n of course) as many times as I can :-) trying to place breakpoints in different files form different sub-packages that I know will run. Letting scons throw exceptions for nothing (like missing Sconstuct file) is also file - the goal is to force indexer to go places because it sees that debugger is going there.
After N runs, (and/or K days). PTVS (you can consider it a plugin) all of the sudden starts recognizing all symbols, packages, sub-packages, only can't penetrate things explicitly hidden behind caches.
Gave up trying to determine which events exactly make the scanner/indexer see the light. Probably something like seeing the number of files at "unexpected" paths being in debugger. Most symbols are visible in debugger immediately, except for the files that load first (scons.py and my own file that I exec from scons.py to inject whatever I want before anything else runs.)
Also I keep PYTHONDONTWRITEBYTECODE=1 to make sure that it always has to load actual .py-s
It might potentially help to have a single file that would exercise something form every sub-package, litter it with breakpoints and let it be run a few times.

Matlab standalone app that was compiled using Guide and deploy tool does not work as designed when deployed

I am not sure if this info helps, but my GUI tool has text boxes for user input, push buttons, drop downs, and an axes to show histogram plot.
The deployment machine is a Windows 7 64 bit. The MCR is installed without any issues (using mcr file packaged with the GUI). The GUI opens in deployed machine. However it does not function properly. Just gives beep sound when using any functionality like pressing a button, no error messages are shown.
I ran the exe file through the dependency walker, and it shows the following errors:
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
LAUNCHERMAIN.DLL
(Error opening file. System cannot find the file specified) for all the above.
Run the executable from a dos window in order to obtain all messages that normally would write to matlab console ...
I'm suspecting that some matlab routines used in your buttons were not embedded during compilation (and the beep corresponding to "warning, error in gui callback function "lalala" is undefined).
NB: I don't think there is any issue for missing dll in dependency walker ... else your exe would not run at all and would wrote "Failed to load module".
You are likely missing the Visual Studio redistributable package. Download and install it on the deployed machine.

Why is matlab's psychtoolbox failing to detect the Screen mexfile when running AssertOpenGL?

I've managed to install the psychtoolbox-3 from the NeuroDebian repository without any explicit errors, but running AssertOpenGL yields this very verbose error message.
My system specs are as follows: Intel-based PC with Ubuntu 12.04 LTS
I've tried adding ~/Documents/MATLAB and all it's subdirectories to the Matlab pathdef, as this is where I pointed the DownloadAdditionsForNeuroDebian function to. Similarly, I've tried adding /usr/share/octave/site/m/psychtoolbox-3/ and it's subdirectories to the matlab path as well.
The error seems to be originating from a failed call to Screen; according to the above error message, Screen can't be found. That having been said, I'm able to run Screen at the Matlab console, although I get this error:
>> Screen
In place of the expected mex file this placeholder file was executed:
Screen
This mex file seems to be missing or inaccessible on your Matlab path or it is dysfunctional:
Screen.*
Hmm. I cannot find the file on your Matlab path?!?
One reason could be that your Matlab path is wrong or not up to date
for the current Psychtoolbox. You may want to run SetupPsychtoolbox to
fix possible path problems.
??? Error using ==> AssertMex at 210
Missing or dysfunctional Psychtoolbox Mex file for this operating system. Read the help text above carefully!!
Error in ==> Screen at 161
AssertMex('Screen.m');
Running SetupPsychtoolbox yields an error that is very similar to the first one.
I tried installing the suggested packages, but they were all already installed -- nothing seems to work.
I have absolutely no idea where to go from here. Does anyone have any suggestions?
The SetupPsychtoolbox command seems to have a bug. What is happening for you (and for me, when I tried this) is that the folder containing Screen.mex is being placed at the bottom of the search path. Here's how to fix;
type "pathtool" at the Matlab commandline
find the PsychtoolboxAddons entry and move it to the top (for me this was /usr/share/psychtoolbox-3/PsychtoolboxAddons)
If you don't have a folder PsychtoolboxAddons you may need to follow the instructions at http://docs.psychtoolbox.org/DownloadAdditionsForNeuroDebian
Don't forget to move your personal Matlab directory to the top also (the SetupPsychtoolbox command moves your personal directory to be underneath it's directories, which is a bit mean).
Save the path. Don't ever run SetupPsychtoolbox again!
Good luck!

How to package a PySide/Phonon app under Mac OSX?

I have a PySide/Phonon app (developed for and working flawlessly on Windows) that I need to "port" to Mac OSX - where I have no development experience whatsoever.
The app works as expected if I just run the Python file - the problems arise when I try to package it (which I need to do) with py2app.
If I leave the resulting .app as is, Phonon doesn't work, because it fails to load the required phonon_backend ; if I add the plugin path to qt.conf, as various sources suggest, Phonon seems to load (that is, I don't get the corresponding error message anymore), but I start getting the "so-and-so library is loaded twice, one will be used, which one is undefined" error, and the app crashes right away.
Finally, if I try to use the macdeploy_qt tool, I receive a message to the effect of "no external framework" and the results are functionally equivalent to what I get without using the tool, except there are a few more plugins in the relevant directory.
Any ideas/pointers/tutorials/etc? I'm using PySide1.1.1 for Qt4.7, by the way, and Python.org python binaries (otherwise py2app can't even start to build a standalone app, it seems).
I suggest you do it like in this tutorial.
Then you just have to add the following line somewhere at the top of your main module:
QApplication.setLibraryPaths([os.path.join(os.environ['_MEIPASS2'], 'qt4_plugins'), os.environ['_MEIPASS2'] ])
For PyInstaller >1.5 the following code should be used instead:
QApplication.setLibraryPaths([os.path.join(sys._MEIPASS, 'qt4_plugins'), sys._MEIPASS])