Trying to use wxPython on a Raspberry Pi - python

I have installed wxPython on my RPi using
sudo pip3 install wxPython-4.0.7.post2-cp37-cp37m-linux_armv7l.whl
But when I attempt to run my python program (which works on my windows machine), I get
Traceback (most recent call last):
File "TrainingUI.py", line 2, in <module>
import wx.media
File "/usr/local/lib/python3.7/dist-packages/wx/media.py", line 13, in <module>
from ._media import *
ImportError: libgstreamer-0.10.so.0: cannot open shared object file: No such file or directory
I see that the media.py file has the from ._media import * line in it, but I don't know what it means. I used ls -a to see that there is no file named ._media, and I'm not experienced enough with python to know what else it might refer to.
How can I get this wx distribution to work with my python3.7 on the RPi?

We (eventually) found:
sudo apt-get install libgstreamer-plugins-base0.10-0
and the error when wx.media is imported is now gone. We can't get MediaCtrl to work, but that's for another post...

Related

I'm trying to use tkinter on python in sublime text on ubuntu but i keep getting a error

So i'm trying to import tkinter in sublime text configured to python3.8 but i keep getting this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Can anyone help me because I really want to get back on working with school projects
Are you importing tkinter? If you do have the import, it probably needs to be installed:sudo apt-get install python3-tk
Otherwise, post your code.
import tkinter
and if not installed :
sudo apt-get install python3-tk

trouble loading jedi-vim after install

My issue is possibly similar to link
but thought I'd ask jic. I'm on osx and trying to use jedi-vim. I installed jedi using pip and then jedi-vim by cloning into the dir that my vim config uses for loading packages. this one for reference. When I start vim with a python program I get the "Please install Jedi if..." message. I cloned vim 74 and configured with +python and +conceal. After still getting the error I looked into the code and found it was an import error.
As an aside, this isn't the best help message. Better might be "Unable to import jedi. Have you installed Jedi?"
I tried import jedi from within vim, as :python import jedi
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0- py2.7.egg/jedi/__init__.py", line 41, in <module>
from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0 py2.7.egg/jedi/api/__init__.py", line 16, in <module>
from jedi.parser import Parser, load_grammar
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0-py2.7.egg/jedi/parser/__init__.py", line 21, in <module>
from jedi.parser import tree as pt
ImportError: cannot import name tree
If this is a build issue, is there a good reference for building vim on mac?

Pushbullet on python throws import error due to python-magic unable to find libmagic?

I'm trying to use PushBullet.py which uses python-magic which in turn uses libmagic.
I have followed the dependencies instructions and installed Cygwin and copied the three files to Windows\system32 directory but still getting the following error:
Traceback (most recent call last):
File "C:\New Python ActiveX Scripting Engine.py", line 1, in <module>
from pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\__init__.py", line 2, in <module>
from .pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\pushbullet.py", line 4, in <module>
import magic
File "C:\Python27\lib\site-packages\magic.py", line 161, in <module>
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
EDIT
If I put cygmagic-1.dll OR cygz.dll into C:\Python27\ and rename it to magic.dll I get the following error:
Traceback (most recent call last):
File "C:\New Python ActiveX Scripting Engine.py", line 1, in <module>
from pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\__init__.py", line 2, in <module>
from .pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\pushbullet.py", line 4, in <module>
import magic
File "C:\Python27\lib\site-packages\magic.py", line 143, in <module>
libmagic = ctypes.CDLL(dll)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
If I put cygwin1.dll into C:\Python27\ and rename it to magic.dll I get the following error:
Traceback (most recent call last):
File "C:\New Python ActiveX Scripting Engine.py", line 1, in <module>
from pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\__init__.py", line 2, in <module>
from .pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\pushbullet.py", line 4, in <module>
import magic
File "C:\Python27\lib\site-packages\magic.py", line 185, in <module>
magic_open = libmagic.magic_open
File "C:\Python27\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "C:\Python27\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'magic_open' not found
I'm doing this on Windows 7 64bit running Python 32bit 2.7.8 (fresh install today to try and resolve this problem).
Does anyone know how to resolve the problem?
EDIT: Tried on a further 5 different windows computers and all 5 have the same problem(s).
I had the same problem with python-magic and solved it by fixing the following line in the magic.py file (C:\Python27\lib\site-packages\magic.py in my PC):
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1')
Since I've installed libmagic from Cygwin, the DLL was named cygmagic-1.dll. So I simply added another choice in the previous line:
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') \
or ctypes.util.find_library('cygmagic-1')
Don't forget to add cygwin\bin to your PATH.
EDIT:
It seems that this issue has been addressed on the GitHub repository.
EDIT2:
These are the steps I followed to make PushBullet.py work on my machine:
Install PushBullet.py via pip (pip install PushBullet.py);
Install libmagic from Cygwin;
Add C:\cygwin\bin\ to the PATH environment variable;
Change the magic.py file as I've explained above. (In my case the error was on line 139)
From the Windows paths in your traceback listings I guess that you are trying to execute PushBullet script from Windows version of Python. Why did you install Cygwin if you are not using it? Python for Windows really won't use Cygwin's DLLs.
You have to execute PushBullet.py from Cygwin using a Python for Cygwin, not from Windows Console using a Python for Windows. That means execute for example bash (something like C:\cygwin64\bin\bash.exe --login -i) and from bash execute PushBullet script: python PushBullet.py.
It expects, that you have Python and python-magic for Cygwin (for Cygwin! not Windows version) already installed.
Copying DLLs to your system directories is nonsense, don't do it. Renaming them is uber-nonsense. How did you expect it could work? Each library is specific, you can't just rename it to change how it works internally.
I'm already using PushBullet for some time, so I was interested in this particular Python script. I'm also using the Cygwin for years. So I have installed PushBullet library:
pip install pushbullet.py
Then I have created very simple script test.py:
#!/usr/bin/python
from pushbullet import PushBullet
pb = PushBullet('my_access_token')
success, push = pb.push_note("Testing title", "Hello world!")
When I executed it using ./test.py I got an error message, that I'm missing magic library, so I installed python-magic library using Cygwin's setup utility.
I executed it again and voila - I have "Hello world!" message on my phone. Done.
Just a note again: I have executed it from the Cygwin's shell (zsh, but you'll have bash I guess), not from Windows Console. I also didn't use Python for Windows but Cygwin's version. Don't mix Windows and Cygwin executables!
So dumb-proof steps would be:
download and execute setup.exe from Cygwin.com
install python and python-magic
execute Cygwin's shell (you can execute "Cygwin Terminal" from your Start menu or just execute C:\cygwin64\bin\bash.exe --login -i for example from "Run" dialog or Windows Console)
install pip (see for example Pip install not functioning on windows 7 Cygwin install)
install PushBullet library: pip install pushbullet.py
prepare your testing script
execute it: python testing_script.py or just testing_script.py if it contains the shebang line and is executable
it should work, if not, post your errors, please
Thank you for a tip to useful library :)
You cannot mix Cygwin and MSVCRT binaries. Therefore, in order to use python-magic with the Windows Python, you must get a Windows-compiled libmagic and fix magic.py to find the libmagic DLL.
Otherwise, if you want to use Cygwin's python-magic as-is, you need to use Cygwin's python packages.

Ropevim error in mac os 10.8.4

I use ropevim perfectly in Ubuntu system,
but i got lots of lots error.
i use homebrew to install macvim and python
and follow the tutorial.
http://wizardmode.com/2012/07/mountain-lion-and-homebrew-vim-importerror-no-module-named-site/
I wander know is the ropevim are very buggy or not practical in mac os system.
because the discussion is not popular?
or is there any better solution in vim for Python on mac os?
Thanks very much...it's annoying me lots of time
>>> import rope
>>> import ropevim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ropevim-0.3_rc-py2.7.egg/ropevim.py", line 10, in <module>
import vim
ImportError: No module named vim
and when I put the ropevim.vim in .vim/plugin
I will got the error when using vim
/install/ropehg/ropemode:vim la
Error detected while processing function LoadRope:
line 3:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/pyt
hon2.7/site-packages/ropevim-0.3_rc-py2.7.egg/ropevim.py", line 3, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/pyt
hon2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/pyt
hon2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions
/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/
2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2
.7/lib-dynload/_io.so
I encountered a very similar stack trace when setting up some vim extensions from this page http://sontek.net/blog/detail/turning-vim-into-a-modern-python-ide
I believe the problem comes from incompatibilities between 'macport' and native python libraries, and that the native version of vim tries to pull from both.
I ultimately resolved my problem by using macport to install vim with python27 variant.
sudo port install vim +python27
The default configuration of macport's vim is without 'python' enabled.

Getting python MySQLdb to run on Ubuntu

I created a virtualbox with a fresh install of ubuntu 9.10.
I am trying to get MySQLdb to run on python but I'm failing at the import MySQLdb
I first tried sudo easy_install MySQL_python-1.2.3c1-py2.6-linux-i686.egg and then sudo apt-get install python-mysqldb.
Both apparently installed ok, but gave me the following error message when in python I have the import line:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/MySQLdb/__init__.py", line 19, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 7, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
I have already installed MySQL and it is running, if that matters at all.
I tried following this, but failed in step 2
Your MySQLdb egg installation looks like it is not working properly. You should go into /usr/local/lib/python2.6/dist-packages and remove it.
The Ubuntu python-mysqldb package should work fine. Unless you have a good reason, you should stick to your distribution's package manager when installing new software.

Categories