I recently updated to SimpleCV 1.3. When I try to run examples I get the following:
objc[92210]: Class SDLTranslatorResponder is implemented in both /Library/Frameworks/SDL.framework/Versions/A/SDL and /usr/local/lib/libSDL-1.2.0.dylib. One of the two will be used. Which one is undefined.
objc[92210]: Class SDL_QuartzWindow is implemented in both /Library/Frameworks/SDL.framework/Versions/A/SDL and /usr/local/lib/libSDL-1.2.0.dylib. One of the two will be used. Which one is undefined.
objc[92210]: Class SDL_QuartzWindowDelegate is implemented in both /Library/Frameworks/SDL.framework/Versions/A/SDL and /usr/local/lib/libSDL-1.2.0.dylib. One of the two will be used. Which one is undefined.
objc[92210]: Class SDL_QuartzView is implemented in both /Library/Frameworks/SDL.framework/Versions/A/SDL and /usr/local/lib/libSDL-1.2.0.dylib. One of the two will be used. Which one is undefined.
WARNING: You need the python image library to save by filehandle
WARNING: You need the python image library to save by filehandle
WARNING: You need the python image library to save by filehandle
Considering this is related to the pygame installations before, when I remove the old pygame folders (There are few of them) I get the error: "ImportError: No module named pygame".
How can I get rid of this? This is something I must take care of until Tomorrow night.
ImportError means the correct folder isn't in your PYTHONPATH environment variable.
Related
I wrote a library in Cython that has two different "modes":
If rendering, I compile using GLFW.
If not rendering, I compile using EGL, which is faster, but I have not figured out how to render with it.
What is the recommended way to handle this situation?
Right now, I have the following directory structure:
mujoco
├── __init__.py
├── simEgl.pyx
├── simGlfw.pyx
├── sim.pxd
└── sim.pyx
simEgl.pyx contains EGL code and simGlfw.pyx contains GLFW code. setup.py uses an environment variable to choose one or the other for the build.
This works ok, except that I need to recompile the code every time I want to switch between modes. There must be a better way.
Update
I agree that the best approach is to simultaneously compile two different libraries and use a toggle to choose which one to import. I already do have a base class in sim.pyx with shared functionality. However this base class must itself be compiled with the separate libraries. Specifically, sim.pyx depends on libmujoco.so which depends on either GLFW or EGL.
Here is my exhaustive search of possible approaches:
If I do not compile an extension for sim.pyx, I get ImportError: No module named 'mujoco.sim'
If I compile an extension for sim.pyx without including graphics libraries in the extension, I get ImportError: /home/ethanbro/.mujoco/mjpro150/bin/libmujoco150.so: undefined symbol: __glewBlitFramebuffer
If I compile an extension for sim.pyx and choose one set of graphics libraries (GLFW), then when I try to use the other set of graphics libraries (EGL) this does not work either unsurprisingly:
ERROR: GLEW initalization error: Missing GL version
If I compile two different versions of the sim.pyx library, one with one set of libraries, one with the other, I get: TypeError: unorderable types: dict() < dict() which is not a very helpful error message, but appears to result from trying to share a source file between two different extensions.
Something like option 4 should be possible. In fact, if I were working in raw C, I would simply build two shared objects side by side using the different libraries. Any advice on how to get around this Cython limitation would be very welcome.
(This answer is just a summary of the comments with a bit more explanation.)
My initial suggestion was to create two extension modules defining a common interface. That way you pick which to import in Python but be able to use them in the same way once imported:
if rendering:
import simGlfw as s
else:
import simEgl as s
s.do_something() # doesn't matter which you imported
It appears from the comments that the two modules also share a large chunk of their code and its really just the library that they're linked with that defines how they behave. Trying to re-use the same sources with
Extension(name='sim1', sources=["sim.pyx",...)
Extension(name='sim2', sources=["sim.pyx",...)
fails. This is because Cython assumes that the module name will be the same as the filename, and so creates a function PyInit_sim (on Python 3 - Python 2 is named slightly differently but the idea is the same). However, when you import sim1.so it looks for the function PyInit_sim1, fails to find it, and gives an error.
An easy way round it is to put the common code in "sim.pxi" and use Cython's largely obsolete include mechanism to textually include that code in sim1.pyx and sim2.pyx
include "sim.pxi"
Although include is generally no longer recommended and cimport is preferred since it provides more "Python-like" behaviour, include is a simple solution to this particular problem.
There is a RenPy-based game that uses custom Python classes for some game objects.
Recently we renamed some modules and classes as part of refactoring. This broke loading of old game saves because Pickle can't find classes.
The Pickle itself supports a mechanism to properly handle situation with class renaming: https://wiki.python.org/moin/UsingPickle/RenamingModules
However I can't apply this code to a RenPy game because save/load process is controlled by RenPy in it's loadsave.py module. Is there a way to fix loading without patching RenPy code? Any monkeypatch ideas?
What I usually do when I move stuff around in Ren'Py is to just create an alias from the old name of the class to the new name. That's enough for pickle - it looks up the old name, and creates a class with the new name.
For example, if I had
class OldClass(object):
pass
and wanted to rename it to NewClass, I would have the code:
class NewClass(object):
pass
OldClass = NewClass
This works across modules, too.
I'm currently building a new CakePHP app with version 3.0.0-RC1, and trying to install and use the jasig/phpCAS plugin. Using this guide, I've run the following command from the command prompt: composer require jasig/phpcas
This correctly copies the jasig/phpcas files into the vendor directory of my app, but one of the other files that the guide says should be updated (vendor/cakephp-plugins.php) doesn't even exist.
I've had a tough time accessing the plugin. I want to be able to call its static methods, and I keep getting errors of the form: Error: Class 'App\Controller\phpCAS' not found. (The exact directory in the error changes depending on where I'm calling the method from.)
I don't know if this is due to not having the cakephp-plugins.php file, or if I'm not calling the plugin correctly. It's my understanding that if the plugin is loaded I should just be able to call static methods on it like this: phpCAS::methodName()
First of all jasig/phpcas is not a CakePHP plugin. And the vendor/cakephp-plugins.php file is created by the CakePHP plugin installer, so if you don't see such a file, you seem to have either not installed any plugins yet, or you are not using a recent version of the installer, as the creation of this file has been introduced just recently.
Regarding the error about the class not being found, you are missing the leading namespace separator (\phpCAS::methodName()) to access the class in the global namespace, respectively you are missing a proper import (use phpCAS;) that would make the class available in the current namespace.
In case you are not familiar with namespaces, you may want to start with: http://php.net/namespaces
I tried to build a shared library using wx and STL, and failed in an error of "multiple definition of". Please refer to:
https://code.google.com/p/gppanel/issues/detail?id=7
The declaration of wxPointListNode is not found in the sources. The suspicious lines are like these:
include/mathplot.h:85:WX_DECLARE_LIST(wxPoint, PointList);
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
include/gpLineLayer.h:16:typedef std::deque<mpPointLayer*> mpPointList_t;
What the problem is?
Without the actual code this is just a guess, but I suspect that
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
generates the full definition of PointList, including a non-templated method wxPointListNode::DeleteData. mathplot.h is included by all of the .cpp files (gpPanel.cpp, gpSeries.cpp, and baseData.cpp). Each cpp file is compiled into a .o file, so each has its own definition of DeleteData, and when you try to link the .o files together into lib/libgpPanel.so the linker issues the errors you're reporting.
The definition of the method needs to be in its own cpp file that's compiled and linked in.
All wxWidgets methods with DEFINE in their name expand into a definition of something and a definition can only be used once in a module, so it typically can't appear in a header file (unless you can guarantee that it's included by only a single source file). So just don't put it there.
Moreover, if this is your code, you should avoid using the legacy WX_DECLARE_LIST macro at all and just use std::list<> or std::vector<> instead. Or, if you really want to use only wx (which can only be important if you are targeting some embedded platform without good STL implementation), then use wxVector<>.
I am trying to edit an already existing Flex project, and I see a warning on the line
"import com.Adobe.utils.StringUtil;" and the warning it shows is
Multiple markers at this line:
-mx
-The import utils could not be found.
-The import StringUtil could not be found.
so what could be the problem?
Well I was wondering what is the difference between import com.Adobe.utils.StringUtil; and import mx.utils.StringUtil;
com.adobe.utils.StringUtil and mx.utils.StringUtil are different classes. From the manual of mx.utils.StringUtil:
The StringUtil utility class is an all-static class with methods for working with String objects within Flex.
Mark that within Flex part.
And com.adobe.utils.StringUtil is part of Adobe's as3corelib which is a pure AS3 library and offers different methods. You need to add the as3corelib's StringUtil to remove the warning.
com.adobe.utils.StringUtil is from the as3corelib -- https://github.com/mikechambers/as3corelib
If this is not included in your project, then flex can't find it. You can either include it or change all imports to use the mx path. However, there might be a specific reason the as3corelib was included in the old project, so be aware of that.