How to use gexiv2 in python? - python

I just compiled exiv2 and gexiv2 for my debian machiene and now I want to start working with gexiv2 to edit IPTC data using python. The gexiv2 website presents the following line of code:
from gi.repository import GExiv2
But that already results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gi.repository
I can't even import gi so I think I'm missing another package!? What do I have to do to make this work as expected?
UPDATE: I upgraded my OS to the newest debian version. I can import gi now, but I'm still having trouble with GExiv2.
The following error occurs when importing GExiv2:
>>>from gi.repository import GExiv2
ERROR:root:Could not find any typelib for GExiv2

Hi i had the same problem i fixed it by installing gir1.2-gexiv2-0.4

I believe the package you need is python3-gi or, if you're using Python 2, python-gi.

Same problem here, I solved it by installing gir1.2-gexiv2-0.4 AND python-gobject

Related

How to install missing wx module on Python 2.5?

I have developped a tool under python 2.5 and can't upgrade to a newer python version as I need to use an API developped under python 2.5 as well.
I recently tried my tool under another machine and it seems it hasn't wx module installed as you can see below:
>>> import wx
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named wx
So I searched for the wxpython source. However once I tried to install the source with:
D:\tmp\wxPython-4.0.0b2>c:\Python25\python.exe setup.py install
I got following error:
Traceback (most recent call last): File "setup.py", line 15, in
from setuptools import setup, find_packages ImportError: No module named setuptools
I can't either install whl files as I don't have pip.
So, how can I install wxpython for python 2.5 under Windows?
Is there any executable there in the web that I couldn't find? May there be a workaround by copying the wx module from a python directory from another computer?
As I had to install wxpython 2.7.2.0 I finally got it from wxPython2.7-win32-ansi-2.7.2.0-py25.exe.
As stated in Patrick's comment all wxpython executables for any version are under https://sourceforge.net/projects/wxpython/files/wxPython/

Not able to import Python packages

Not able to install any packages
I've tried VLC package from https://wiki.videolan.org/python_bindings
and got a traceback.
Now I am trying pygame module and this is what i get
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pygame
File "C:\Users\Vineeth\AppData\Local\Programs\Python\Python36-32\lib\pygame\__init__.py", line 133, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Please help i am pretty new to python
There are some release binaries for Python3.x, 64bit Windows at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
I suggest you download it from that site and install it. It works for me. If you are using Windows ,it is a good way to install some packages,like lxml matplotlib.
Also you check out this question.
Hope this helps.
I tried to execute your statements and the imports worked fine for me. I have a 64bit Windows OS. And my python version Python 3.5.2 - 64bit.
Check if you have other Python versions, if you have removed them, make sure you did that right.
Ultimately I would just suggest you to do pip install pygame. The version compatibility will be handled by pip itself.

"Expected in: flat namespace" error when importing networkx in python

I'm getting a strange error which I can't make sense of.
On Python 2.7, I installed the py27-networkx package using MacPorts. When I try to import networkx as nx, I get the error below. The only line in my network.py file is the import one.
Any ideas on how to debug this to work out what's happening?
Traceback (most recent call last):
File "network.py", line 1, in <module>
import networkx
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/__init__.py", line 43, in <module>
from networkx import release
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/release.py", line 45, in <module>
import subprocess
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 427, in <module>
import select
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
Update
Ran a few pieces to help diagnose. Hope it helps someone provide some insight and a solution to this for me.
which python gives me /opt/local/bin/python (I have the standard Mac OS X python, but am using a MacPorts installed version of python2.7)
Running import networkx from the python prompt produces no errors
Anything else I can try?
I also had this error and i fixed by upgrading python27 with macports.
Update macports to the latest version:
sudo port selfupdate
List outdated packages (python27 was outdated for me, when I was getting the import error):
sudo port outdated
Update the outdated packages:
sudo port upgrade outdated

"ImportError: cannot import name urandom", virtualenv is not installed

I am running ubuntu 11.10 with python 2.7.2. When I import the random module I get the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom
Googling shows that this appears to be a common problem among people using virtualenv. The solution usually proposed is to simply re-run virtualenv on the directory you're having trouble with. However, I do not have virtualenv installed. Could anyone offer me any guidance as to what to do?
I have looked at ImportError: cannot import name "urandom"; it did not help, since I do not have virtualenv installed (my $ENV is empty, just in case anyone was curious).
I have also looked at Python ImportError cannot import urandom Since Ubuntu 12.04 upgrade; it also did not help, since I am not using virtualenv.
Thanks in advance!

Gdal will not import after several installs (Mac OSX)

Using Macports,
I've tried to install: gdal, py27gdal, and gdal-grass. All so I can import gdal into python 2.7.2.
Neither have been successful.
When I type:
port list installed
I see the installed modules:
gdal-grass #1.4.3 gis/gdal-grass
gdbm #1.8.3 databases/gdbm
py27-gdal #1.7.1 python/py27-gdal
And when I run python to import the module:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gdal
What am I doing wrong?
Are you using the MacPorts python2.7? Try launching Python this way:
/opt/local/bin/python2.7
I'm not 100% sure if this solves your problem, but gdal is in the osgeo namespace. So you should try importing gdal like this:
from osgeo import gdal
The gdal namespace itself is deprecated.

Categories