Error using pygraphviz on Mac OSX Lion - osx-lion

After some struggle installing pygraphviz on Mac OSX Lion ([sudo] easy_install pygraphviz) I've tried to use it, but it crashes when I import it. Here you can see the error.
Any idea to solve it? Do I should install another aux library...?
>>> import pygraphviz
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/__init__.py", line 54, in <module>
from agraph import AGraph, Node, Edge, Attribute, ItemAttribute
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/agraph.py", line 19, in <module>
import graphviz as gv
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/graphviz.py", line 7, in <module>
import _graphviz
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/_graphviz.so, 2): Symbol not found: _Agundirected
Referenced from: /Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/_graphviz.so
Expected in: dynamic lookup

Related

Visual Studio Code - I cant import requests

I am trying to install requests library using pip install requests.
Could not import runpy module
Traceback (most recent call last):
File "C:\Users\ga\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 15, in
import importlib.util
File "C:\Users\ga\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 14, in
from contextlib import contextmanager
File "C:\Users\ga\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 5, in
from collections import deque
ModuleNotFoundError: No module named 'collections'
PS C:\Users\gae\Documents\MoldingMachine>
keeps telling me that. I don't know why it doesnt let me install it

swift throws python errors from terminal

I'm getting an error whenever I try to start swift related to python. How do I fix this?
bash-3.2$ swift --version
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0
bash-3.2$ swift
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in
import weakref
File "/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
I get the same error, because the swift REPL uses the python interpreter which homebrew installed at /usr/local/bin/python.
To avoid this you can
export PATH=/usr/bin:$PATH
swift
or
PATH=/usr/bin:$PATH swift

Can't launch ipython after El Capitan upgrade

Does anyone know how to undo the changes to paths and permissions wrought by upgrading to El Capitan. Specifically, it appears that OS X is now using the system python instead of my Canopy installation.
These look ok:
Michaels-Mac-mini:~ mellis$ which python
/Users/mellis/Library/Enthought/Canopy_64bit/User/bin/python
Michaels-Mac-mini:~ mellis$ which ipython
/Users/mellis/bin/ipython
But trying to launch ipython fails:
Michaels-Mac-mini:~ mellis$ ipython
Traceback (most recent call last):
File "/Users/mellis/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/pyth on/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: ipython==0.11
A complete update of my installed Canopy packages including ipython seems to have fixed the problem.

scipy not compiling on Python 3.4

When importing scipy:
from scipy import signal
I get the errors:
Traceback (most recent call last):
File "F:\Desktop\Programming\Python\Sample Programs\src\butter.py", line 7, in <module>
from scipy import signal
File "C:\Python34\lib\site-packages\scipy\signal\__init__.py", line 280, in <module>
from .bsplines import *
File "C:\Python34\lib\site-packages\scipy\signal\bsplines.py", line 12, in <module>
from scipy.special import comb, gamma
File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 601, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.`
I am running Eclipse on windows 7. I installed scipy successfully using
pip3.4 install "scipy-0.16.0rc1-cp34-none-win32.whl"
Can you tell me how I can get scipy to work with this simple program on Windows 7?
As mentioned prior, the easiest way to get SciPy running on windows is to simply download the Anaconda distribution. Be sure to obtain the version you want. It works out of the box. Plus you get Jupyter/IPython Notebook which is a really cool interactive GUI interface. It's almost like working in Matlab!
http://continuum.io/downloads

py2app crashes with PIL errors on earlier versions of OS X

A similar question was asked before by someone else: https://stackoverflow.com/questions/23600028/py2app-app-crashes-on-earlier-mac-os-x-versions
I have an app that runs fine on my machine (OSX 10.9.4), but when I move it to another machine running 10.7.5, the app crashes on start up. I get the following messages in console:
Traceback (most recent call last):
File "/PATH_TO_APP/APP.app/Contents/Resources/__boot__.py", line 3
_recipes_pil_prescript(['Hdf5SubImagePlugin', 'FitsStubImagePlugin', 'SunImagePlugin', 'GbrImagePlugin', 'Jpeg2KImagePlugin', 'MicImagePlugin', 'FpxImagePlugin', ImImagePlugin', ...
File "/PATH_TO_APP/APP.app/Contents/Resources/__boot__.py, line 3
from PIL import Image
File "PIL/Image.pyc", line 62, in <module>
File "PIL/_imaging.pyc", line 14, in <module>
File "PIL/_imaging.pyc", line 10, in __load
ImportError: dlopen(/PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so, 2): Symbol not found: ___sincos_stret
Referenced from /PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so
Expected in: /usr/lib/libSystem.B.dylib
in /PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so
Earlier, to get around this error, I just uninstalled pillow. I'm not sure why pillow libraries were being added to the app to begin with, since I didn't think I was using it. But now, when attempting this workaround, I get another error:
Traceback (most recent call last):
File "/PATH_TO_APP.app/APP.app/Contents/Resources/__boot__.py", line 384, in <module> _recipes_pil_prescript([])
File "/PATH_TO_APP.app/APP.app/Contents/Resources/__boot__.py", line 344, in _recipes_pil_prescript from PIL import Image
File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 62, in <module>
ImportError cannot import name _imaging
Apparently I'm using PIL now somehow. My script imports the following:
from __future__ import division
import easygui as eg
import os, zlib, re, datetime, getpass, tkMessageBox, sys
import zipfile as z
import Tkinter as tk
from tkFileDialog import askdirectory
from optparse import OptionParser
Here's my setup.py:
from setuptools import setup
APP = ['zipperscript.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'excludes': ['']}
setup(
app=APP,
name="Zipperscript_HI_50",
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
version="Hawaii branch 4.0.50"
)
I'm not sure that the OS version is causing the problem, but that's my theory right now. I'm not sure how to proceed. Any help or suggestions are greatly appreciated.
I encountered a similar problem while using buildout on Mac OS 10.8.5. It seems that the pre-compiled packages available on Pypi have been compiled on newer versions of OS X and unfortunately insufficiently tested on older versions.
The solution is to install pillow from source instead. Download the source, and run pip install your_downloaded_file. You may need to install dependencies such as libjpeg and zlib beforehand.
After doing this I do not encounter the errors anymore and have pillow version 5.4.0 installed.