I have trouble setting up the Python-Path for it, I don't really know what to do here. I use elementary OS, which should be similar enough to Ubuntu.
My code so far is this:
#!/usr/bin/python3
import gi
gi.require_version('GTK', '3.0')
When I run the script, the system reports that there is no module named "gi".
However, when I try
sudo apt-get python3-gi
I get told that it is installed already.
I tried
print(sys.path)
and
locate python3-gi
which gave me back some directories. But there were too many, so I don't know what, if this is at all the right way, to to copy where.
Addendum:
Okay, so doing type export PATH="$PATH:/usr/local/bin/python-gi3" yields export is a shell builtin
bash: type: PATH=/home/ge0rg/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/bin/python3-gi: not found
uname -r yields 3.19.0-51-generic.
In the meantime, I also tried reinstalling python3-gi, to no avail. Also, since python3-gi seems to b located in /usr/lib/python3/dist-pacakges, I tried going into python and doing sys.path.append("/usr/lib/python3/dist-pacakges") where the above mentioned folder was not included before. However, after doing this import gi gives the same error as before: >>> import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'gi'
EDIT: Also, locate python3-gi yields:
`/usr/share/doc/python3-gi
/usr/share/doc/python3-gi-cairo
/usr/share/doc/python3-gi/changelog.Debian.gz
/usr/share/doc/python3-gi/copyright
/usr/share/doc/python3-gi-cairo/changelog.Debian.gz
/usr/share/doc/python3-gi-cairo/copyright
/usr/share/lintian/overrides/python3-gi
/var/lib/dpkg/info/python3-gi-cairo.list
/var/lib/dpkg/info/python3-gi-cairo.md5sums
/var/lib/dpkg/info/python3-gi-cairo.postinst
/var/lib/dpkg/info/python3-gi-cairo.postrm
/var/lib/dpkg/info/python3-gi-cairo.shlibs
/var/lib/dpkg/info/python3-gi.list
/var/lib/dpkg/info/python3-gi.md5sums
/var/lib/dpkg/info/python3-gi.postinst
/var/lib/dpkg/info/python3-gi.postrm
/var/lib/dpkg/info/python3-gi.prerm
/var/lib/dpkg/info/python3-gi.shlibs`
however, /usr/lib/dist-packages/gi also exists, but locate gi just gives back a whole array of mostly unrelated results.
I am guessing its installed in /usr/local/bin/python-gi3 . If you see it there, open your shell and type type export PATH="$PATH:/usr/local/bin/python-gi3" to set the path
Related
So my case is a tricky one.
I first installed OpenCV2.4.8 and started it using for python2.7. Later I planned to migrate to OpenCV3.0.0. Both the times during installation I followed the official documentation procedure. Everything was working fine until I realized that OpenCV3 doesn't have SIFT() and SURF() modules. After a bit of searching I found they are present in opencv_contrib. First I tried to install that but for some reason I couldn't.
Later I found that these modules are present in OpenCV2.4.11 and planned to install that. Again following the official procedure I installed OpenCV2.4.11 got the same SIFT() importerror. Upon checking the OpenCV __version__ in python2 and python3 I found the following
python2: "2.4.8"
python3: "3.0.0"
For checking the version I used the following code:
from cv2 import __version__
print(__version__)
Unfortunately I don't have a lot of memory in /home, so I had deleted OpenCV2.4.8 and OpenCV3.0.0 build folders after installing. Therefore, I tried to manually remove OpenCV2.4.8 and OpenCV3.0.0 and deleted all opencv the libs from /usr/local/libs/ and sub-directories and all the opencv bins from /usr/local/bins/ (following answer in this question).
After removing all opencv files I again reinstalled OpenCV2.4.11 and tried to run my code. It failed at the import step in python2 giving
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
in python3
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libopencv_core.so.3.0: cannot open shared object file: No such file or directory
I again checked if OpenCV2.4.11 is present or not and its there but the python hasn't updated the previously stored link to opencv lib. I'm stuck at this error since 2 days with no solution. Any help will be appreciated.
EDIT:
Is there some shared library lookup file which python uses to store all the locations of shared libraries? If not how does this work (how python recognizes where to look for opencv as opencv is not listed in pip freeze)
EDIT2:
I found another mistake. I hadn't enabled -D BUILD_SHARED_LIBS=ON before. This time I kept it ON and rand sudo ldconfig after make and make install. Now I have a libopencv_core.so.2.4 in my /usr/local/lib/. It is a symlink to libopencv_core.so.2.4.11 present in the same folder. After ldconfig when I checked for python2 import cv2 didn't show any error but __version__ still shows '2.4.8'. I double checked for any OpenCV2.4.8 .so file and there are none. How is it still pointing to version '2.4.8'?
Steps for removal:
remove opencv libs by : sudo apt-get purge libopencv*
Verify that whether cv2 is uninstalled by trying import cv2 in python. It should show no cv2 module present
Install opencv2.4.11 by following this sh file
Run sudo ldconfig after sudo make install
Things should usually work but it didn't work in my case because cv2.so was missing from /usr/local/lib/python2.7/dist-packages/. For that manually copy from /<opencv-2.4.11 unzip locaiton>/release/lib/cv2.so to /usr/local/lib/python2.7/dist-packages/. Use sudo for permissions.
Now import cv2 will work and __version__ is '2.4.11'.
Recently, (I have no idea when), I installed this package called pymol. Today when I was trying to copy a list of all my install modules, I encountered this error.
~/Projects$ python -c "help('modules')"
Please wait a moment while I gather a list of all available modules...
Error: unable to initalize the pymol.cmd module
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pymol/cmd.py", line 117, in <module>
from chempy import io
ImportError: cannot import name io
I've tried
sudo pip uninstall pymol
This definitely worked... but it also definitely did not work. It removed the .egg, and pip list tells me it's not installed, but the tool is still there. I open a python prompt and import it with no problem. Now my question is, if I just delete the package, is there anything that could go wrong, (WCS I'm thinking kafkaesque broken dependency fixing for the rest of my natural life.) and is there a standardized, best practice to remove this, or any other package manually.
I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.
I read some articles about Vimscripting with python. I felt very interested. So I tried to figure out how to do vimscripting with python.
But when I tried to import vim, it showed that the module vim wasn't installed. So I searched
on the web, but still haven't find the module to install.
I also tried pip to search automatically, still failed.
Does anyone know where to find the module vim?
I am using fedora 17, and I have installed vim 7.3 and python 2.7.
Thanks in advance.
Here is the error message:
>>> import vim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named vim
It doesn't seem like you need to import it, just make sure your vim is compiled with python support. Check this using vim --version | grep +python. Further, it seems that the vim module is imported automatically when in vim, rendering your import line unnecessary.
it do not work but this will work
:python from vim import *
:python command('echo "Hello World!"')
if you put vim.command(..
You get
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'vim' is not defined
Compile VI with python as described by hd1. You can find the documentation here:
http://vimdoc.sourceforge.net/htmldoc/if_pyth.html
If you want to test
export PYTHONPATH=$HOME/local/lib/python2.7/site-packages
Note that I installed all in local, this is why I use $HOME in PYTHONPATH
Run vi then, type
:python from vim import *
:python vim.command('echo "Hello World!"')
you should see "Hello World!" below.
I installed easy_install under windows, and installed pygraph but the commad import gv in the example taken from here doesn't work:
What is gv lib? what import gv does?
I get this error :
Traceback (most recent call last):
File "C:\Python27\graph.py", line 11, in <module>
import gv
ImportError: No module named gv
All the other imports works fine
Try to install libgv-python with your package manager. On Ubuntu:
sudo apt-get install libgv-python
This could have multiple problem sources:
While installing, something went wrong and the module couldn't be installed.
You haven't set your Python Path correctly.
#second example: The module pygraph.readwrite could exists, but it's possible that it hasn't got a submodule called dot.
Of course there are sure other possibile problems, but I think this would be the most likely.
Edit: Have a look at this. Looks like it's the same problem as yours.
For the second problem eventually this discussion may also help.
This seems to be a common issue with python-graph, see the discussion at http://code.google.com/p/python-graph/issues/detail?id=15. gv is GraphViz and apparently something with the place or the bindings of this library is wrong. You might have to modify sys.path, but it might be even more troublesome on Windows.
From python-graph's "Issue 15: import gv":
It appears that graphviz for windows has no python bindings, or they are not
included with the installer, and not available elsewhere.
Furthermore, I can find no mention of libgv-python (the library which gv is from, I
think) ever being available on windows.
You can workaround the absent gv.py by using the command line tools directly.
Assuming you're trying the example code, remove these lines:
sys.path.append('..')
sys.path.append('/usr/lib/graphviz/python/')
sys.path.append('/usr/lib64/graphviz/python/')
import gv
And remove these lines:
gvv = gv.readstring(dot)
gv.layout(gvv,'dot')
gv.render(gvv,'png','europe.png')
And add these lines instead, making sure the path to dot.exe is correct, or is otherwise in your PATH:
f = open('europe.dot', 'a')
f.write(dot)
f.close()
import os
command = '"C:\\Program Files\\Graphviz 2.28\\bin\\dot.exe" -Tpng europe.dot > europe.png'
print command
os.system(command)
os.system('europe.png')
Module gv corresponding to graphviz-python a python binding of graphviz
See : http://www.graphviz.org/Home.php