I can't import igraph on mac 10.6 - macos

I installed igraph for python in my mac but I can't import it. First I installed C core library, then I proceeded with the instalation for python, by doing:
python setup.py build
python setup.py install
Everything seemed to work fine but I can't import igraph from python shell. Just to clear up, I'm not inside igraph source code's folder. And I got this error:
import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/__init__.py", line 30, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 7, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so, 2): Symbol not found: _igraph_vector_destroy
Referenced from: /Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so
Expected in: dynamic lookup
I replaced my folder's name for *, so don't consider it.
I'm running python 2.7 over OS 10.6.7. So there's no pre-compiled version of igraph avaliable (2.5 and 2.6 only). Has this error anything to do with the python version I'm running?
If possible, how can I work this out?

I think the problem is that igraph is installed in /usr/local/lib/libigraph.dylib, but the linker cannot find it when Python tries to load the C core of the igraph module because /usr/local/lib is not on the default library path in Mac OS X. (At least I think so).
First, please check whether libigraph.dylib is really in /usr/local/lib - it should be there. After that, try this:
DYLD_LIBRARY_PATH=/usr/local/lib python -m igraph.test.__init__
This should instruct the linker to look around in /usr/local/lib as well as the default places, and then run Python with the entire igraph test suite.

Related

Python3 cannot find statsmodels.api but I can and so can my linter

I recently got into development with Python running on WSL (Ubuntu 18.04 LTS).
I followed the documentation from here and I'm able to run simple python scripts.
I started playing around with libraries that I installed using the pip3 command such as numpy and pandas and these work fine.
The problem arises when I try to use the statsmodels package.
I've installed it using pip3 install statsmodels
I can see the package in /home/username/.local/lib/python3.6/site-packages/statsmodels I can even see the api.py file in that directory, however, when I type import statsmodels.api as sm as recommended on the statsmodels website I get:
Console output:
username#DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py
Traceback (most recent call last):
File "statsmodels.py", line 5, in <module>
import statsmodels.api as sm
File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package
I've tried uninstalling and reinstalling (did not work)
I really can't see anything that differentiates this package from the others that I've installed. Does anyone have any insights?
Thanks #Vorsprung durch Technik
The issue was that my file name was statsmodels.py.
I'll remember to be more careful when naming my python files.

Unable to run Autokey Ubuntu 18.04

I am relatively new to Linux/Ubuntu (so please take it easy on me) and I am trying to install Autokey to use the text expansion functionality. I have tried installing it from the instructions on the Github page here - https://github.com/autokey/autokey#installation
However, no matter whether I follow the installation process under the Ubuntu/Mint/Debian section or the instructions to install via pip I cannot seem to get the program working.
The installation seems to be successful (running a 'which' command gives the path installed) but clicking on the icon does not launch the program.
I have also tried to install directly from Ubuntu/GNOME software manager but that also will not launch the program once installed.
I have tried installing both the GTK and QT frontends and neither will launch. I don't get an error message or anything. I have opened up the System Monitor to see if a process even appears (however briefly) and there's nothing.
Typing autokey-gtk into Terminal gives:
/usr/local/lib/python2.7/dist-packages/autokey/gtkapp.py:24: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gdk, GObject, GLib
Traceback (most recent call last):
File "/usr/local/bin/autokey-gtk", line 20, in <module>
from autokey.gtkapp import Application
File "/usr/local/lib/python2.7/dist-packages/autokey/gtkapp.py", line 28, in <module>
import service, monitor
File "/usr/local/lib/python2.7/dist-packages/autokey/service.py", line 21, in <module>
from iomediator import Key, IoMediator
File "/usr/local/lib/python2.7/dist-packages/autokey/iomediator.py", line 107, in <module>
from interface import *
File "/usr/local/lib/python2.7/dist-packages/autokey/interface.py", line 29, in <module>
from Xlib import X, XK, display, error
ImportError: No module named Xlib
Can anyone please help? Thank you.
I am a newbie too and installed Autokey 0.90.4, which did not work for me either. Someone suggested I try 0.95.1 because the other version is 7 years old.
I installed the new version with some acrobatics from the Autokey Github page, using the PIP method. At 1st it did not work, but after doing import setuptools it did. That might be a coincidence since it was after installation of the Ak package itself.
I know this sounds convoluted, but I am not familiar (yet?) with Linux. Anyway 0.95 works for me.
install module python-xlib and it will work, like this:
On Deb:
apt install python3-xlib
You might later need python autokey module as well:
pip install autokey

How to import leveldb in Python 3.5 on Windows

I struggled a while to install leveldb package in Python 3.5 on Windows.
https://github.com/happynear/py-leveldb-windows gives some clues on how to install the package. However, even though following all the instruction in the post, I still got a following error when I imported the package leveldb in Ipython prompt:
import leveldb
Traceback (most recent call last):
File "<ipython-input-16-4427bf69c6fb>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Does anyone know how to solve this problem?
The compiled pyd file at https://github.com/happynear/py-leveldb-windows is for Python 3.6 as of 18.03.2019. I had the same error as the OP when trying to use it with Python 3.7. Uninstalling 3.7 and installing 3.6 made it work.

Manually specify library when pyinstaller sees conflicting versions

Is it possible to manually replace or specify the location of a .dylib on Mac OSX when using pyinstaller?
I'm getting the error when trying to open my completed .app
Traceback (most recent call last):
File "DeepMeerkat/main.py", line 3, in <module>
import cv2
File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 546, in load_module
module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: dlopen(/Users/ben/Documents/DeepMeerkat/Installer/dist/Lib/cv2.so, 2): Library not loaded: #loader_path/libpng16.16.dylib
Referenced from: /Users/ben/Documents/DeepMeerkat/Installer/dist/Lib/libopencv_imgcodecs.3.3.dylib
Reason: Incompatible library version: libopencv_imgcodecs.3.3.dylib requires version 48.0.0 or later, but libpng16.16.dylib provides version 45.0.0
Failed to execute script main
I have no problem loading cv2 in python outside of the app, or any other problems with open, which was installed with homebrew.
Poking around, I think it is extremely likely the error comes from pyinstaller grabbing libpng from X11 (/opt/X11/include/libpng16) when it needs to be grabbing from Homebrew's folders (/usr/local/Cellar/libpng/1.6.32/)
How can I use a hook to specify which libpng I want?
I had the same problem, the answer lay in editing the .spec file. Add the following line after a = Analysis...:
a.binaries = a.binaries - TOC([('libpng16.16.dylib',None,None)])
This has the effect of removing the offending dylib from the relevant TOC file which solves the conflict.

Installing PyQt4 in Mac OS X and Maya

I am trying to run PyQt4 in Maya 2014 and I keep getting the error that no modules was found etc.
I am a Mac user on OS X 10.7.5 and I have tried running the installation following this link as my guide.
Unfortunately though I am able to install everything as stated, but as I am unable to get the IDLE.app from MacPorts, thus I tried checking whether the PyQt4 is installed either by terminal or through Maya itself where I typed in from PyQt4.QtGui import *
However both methods still state the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4.QtGui
Can anyone help me through? Or do I still need to install something else just for Maya-usage?
It would seems that the python package in my machine is Python 2.7.1 as depicted from the terminal
For 2014+ you may want to use PySide, which comes with your Maya and won't need separate installation.

Resources