Why is python choking on numpy.core.ma? - python

I'm trying to set up pylab on my mac 10.6.7 32 bit machine; using virutalenv to isolate what I'm doing from everything else (coming from a ruby/rvm background this just makes me feel better--but I'm open to correction if it's not the "python way").
I have the following modules/libs installed:
DateUtils-0.5.1-py2.7.egg-info numpy-1.5.1-py2.7.egg-info
IPython pip-0.8.3-py2.7.egg
configobj.py pylab.py
configobj.pyc pylab.pyc
dateutil pymc
dateutils pymc-2.1beta-py2.7.egg-info
easy-install.pth python_dateutil-2.0-py2.7.egg-info
enthought pytz
ipython-0.10.1-py2.7.egg-info pytz-2011e-py2.7.egg-info
matplotlib scipy
matplotlib-0.91.1-py2.7.egg-info scipy-0.9.0-py2.7.egg-info
nose setuptools-0.6c11-py2.7.egg
nose-1.0.0-py2.7.egg-info setuptools-0.6c12dev_r88795-py2.7.egg
numpy setuptools.pth
The only one I can't account for is enthought; I have never installed their python solution -must be a dependency of something else.
Numpy appears to be working just fine, matplotlib can be imported without issue; both from a shell. When I call just plain ipython no trouble either. But when I try and use pylab I python chokes on numpy.core.ma as in:
File "/Users/davidbgonzalez/.virtualenvs/VirtPy27/lib/python2.7/site-packages/matplotlib/numerix/ma/__init__.py", line 16, in <module>
from numpy.core.ma import *
ImportError: No module named ma
Backing into this I opened the __init__.py and a prompt as alluded to here. Sure enough, ma is found in numpy.ma not numpy.core.ma; verified via import numpy.ma.
I change the offending line:
from numpy.core.ma import * -> from numpy.ma import *
And get a new, very similar, error:
File "/Users/davidbgonzalez/.virtualenvs/VirtPy27/lib/python2.7/site-packages/matplotlib/numerix/npyma/__init__.py", line 7, in <module>
from numpy.core.ma import *
ImportError: No module named ma
But when I change that instance of numpy.core.ma to numpy.ma I get a dreadful:
Bus error
I'm open to any solutions.

For someone else coming googling around, the one liner you search is currently:
pip install -U 'http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.tar.gz/download'

You appear to have a extremely old version of Matplotlib installed. I'm not sure where you got it, but the current version (1.0.1) can be downloaded from http://matplotlib.sourceforge.net/

Related

Python - Unable to find assembly 'OSIsoft.AFSDK'

I am trying to import "clr" in a python script and I have an error with and without "clr" installed. If "clr" is installed, then I get the error:
AttributeError: module 'clr' has no attribute 'AddReference'
If I remove "clr" and install pythonnet (as suggested to fix the "clr" error), then I get this error:
FileNotFoundException: Unable to find assembly 'OSIsoft.AFSDK'.
at Python.Runtime.CLRModule.AddReference(String name)
My imports look like this:
import sys
sys.path.append('C:\\Program Files (x86)\\PIPC\\AF\\PublicAssemblies\\4.0\\')
import clr
clr.AddReference('OSIsoft.AFSDK')
from OSIsoft.AF.PI import *
from OSIsoft.AF.Search import *
from OSIsoft.AF.Asset import *
from OSIsoft.AF.Data import *
from OSIsoft.AF.Time import *
import pandas as pd
from datetime import datetime
It seems like I'm missing something in finding the answer. I have loaded the latest oracle client 14.1 and that folder resided in my python working script environment. thank you for any help!
Try to remove be the wrong 'clr' module. which is mixed up with the one in pythonnet.
pip uninstall clr
pip uninstall pythonnet
pip install pythonnet

osx - Mac - Python 3.5 - ImportError: No module named 'cubicspline' when testing python package

I recently downloaded a package and when testing the package to see if everything works correctly I get the error ImportError: No module named 'cubicspline'. When following the trail to see where is error occurs I found that cubicspline.py (the file not being found) is in the same folder as extcurve_s16.py (the file calling cubicspline).
File "/Users/Austin/anaconda/lib/python3.5/site-packages/isochrones/schlafly/extcurve_s16.py", line 4, in <module>
import cubicspline
I've checked the permissions on the folder and I'm able to both read and write. There is also an __init__.py file in the folder. Any ideas here? I can't figure out why it wouldn't be able to call a file that is in the same folder. Here is the exact chunk of code for reference, as can be seen import numpy works fine.
import numpy
import cubicspline
The issue was resolved by cloning the isochrones package from Github instead of using pip install isochrones. There was some type of issue with the pip version.

Symbol not found: _PyObject_REPR when calling pyobjc function, Python3.5.1

Been looking to get started w/ pyobjc in order to simulate some mouse-events/keystrokes equivalent to ctypes on windows. Ran a clean install of pyobjc (pyobjc-core was downloaded first, then pyobjc). Below is the code that I have been trying out (source):
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(
None,
type,
(posx,posy),
kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, 845, 396);
def mouseclick(posx,posy):
mouseEvent(kCGEventMouseMoved, 845, 396);
mouseEvent(kCGEventLeftMouseDown, 845, 396);
mouseEvent(kCGEventLeftMouseUp, 845, 396);
Which yields the following error as most recent:
File "/usr/local/lib/python3.5/site-packages/objc/__init__.py", line 15, in _update
import objc._objc as _objc
ImportError: dlopen(/usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so, 2): Symbol not found: _PyObject_REPR
Referenced from: /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
Expected in: flat namespace
in /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
Clearly the issue is that _PyObject_REPR is absent from Python3.5, and so the init script fails. Having gone on the bitbucket 'issues' page, I found this. One of the users (Kentzo) amended the pyobjc github to remove the involvement of _PyObject_REPR.
My question: how do I go about correctly installing his amended version? I have attempted the standard 'pip3 install "link"' method, however I cannot seem to install it over my existing pyobjc files. Do I need to manually remove all of the pyobjc files via sudo?
As you can probably tell I'm a bit of a noob, so any guidance would be much appreciated!
Thanks!
To install a working version, you will want to download the correct pyobjc version (Kentzo's), navigate to the downloaded folder in terminal or the command line, and run "python3 setup.py install" from terminal (Mac) or "setup.py install" from the command line (Windows). The setup.py file will handle everything for you.
Download Kentzo's version here, and then open it: https://github.com/GreatFruitOmsk/pyobjc-core/releases/download/v3.0.5.dev0/pyobjc-core-3.0.5.tar.gz.
Once you've opened that downloaded folder, follow the instructions from this page under the Distutils section: https://docs.python.org/2/install/#the-new-standard-distutils.
I don't know whether already having the old pyobjc version will cause trouble, but go ahead and uninstall the previous pyobjc version (with pip3 uninstall like usual), and then start the above steps.

Import Error in __init__.py : No Module named _vlfeat in PyVlfeat

I am trying to run this python rewrite of Vlfeat library.
https://github.com/shackenberg/phow_caltech101.py. I am trying to run the application phow_caltech101.
This is throwing
File "/A/B/C/pyvlfeat-0.1.1a3/vlfeat/__init__.py", line 1, in <module>
import _vlfeat
ImportError: No module named _vlfeat
In the corresponding "init.py" file, I can see it is mentioned as "import _vlfeat". I am new to python, please let me know what is causing this error?
You need to download and install PyVlfeat module.
https://pypi.python.org/pypi/pyvlfeat/
As I see, pyvlfeat has some dependencies, so be sure to download these too:
Boost.Python (tested against version 1.35.0-5)
NumPy (tested against version 1.5.1)
Matplotlib (tested against version 0.99.3)

Scons fails to import _args_from_interpreter_flags

Im trying to compile Godot engine following the instructions here
When I run scons bin/godot as the tutorial says, I get the following error:
scons: Reading SConscript files ...
ImportError: cannot import name _args_from_interpreter_flags:
File "/home/grayfox/github/godot2/godot/SConstruct", line 9:
import multiprocessing
File "/usr/lib64/python2.7/multiprocessing/__init__.py", line 65:
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/usr/lib64/python2.7/multiprocessing/util.py", line 40:
from subprocess import _args_from_interpreter_flags
The SConstruct file starts this way:
EnsureSConsVersion(0,14);
import string
import os
import os.path
import glob
import sys
import methods
import multiprocessing
...
If I try to run python SConstruct I get an error complaining about missing functions defined by scons (i.e. the script fails after doing all the imports).
Commenting import multiprocessing fixes the issue but I don't want to modify that file, as I would have to revert the change if I ever make a pull request. The project is quite active so I believe this has something to do with my local configuration.
Any ideas why the script is failing to import _args_from_interpreter_flags only if I execute it via scons?
[UPDATE]
I did a fresh Gentoo install and the problem persists. I did some tests and I found this:
In a python terminal>
>>> import SCons.Script
>>> from subprocess import _args_from_interpreter_flags
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name _args_from_interpreter_flags
>>> import subprocess
>>> subprocess.__file__
'/usr/lib64/python2.7/site-packages/SCons/compat/_scons_subprocess.pyc'
But the output is different if I do this:
>>> import subprocess
>>> subprocess.__file__
'/usr/lib64/python2.7/subprocess.pyc'
So I update my question: Is this a bug? Can anybody reproduce it in other distros? If it's a bug, should I report it to Gentoo or to SCons?
[ANOTHER UPDATE]
Adding temp.extend([os.path.join(x, 'lib64') for x in prefs]) did't work, same error.
Adding print sys.path at the beginning of the compact module gives:
['/usr/lib64/python-exec/python2.7/scons-local-2.3.0',
'/usr/lib64/python-exec/python2.7/scons-local',
'/usr/lib64/python2.7/site-packages/lib32/scons-2.3.0',
'/usr/lib32/scons-2.3.0',
'/usr/local/lib32/scons-2.3.0',
'/usr/lib64/python2.7/site-packages/lib/python2.7/site-packages/scons-2.3.0',
'/usr/lib/python2.7/site-packages/scons-2.3.0',
'/usr/local/lib/python2.7/site-packages/scons-2.3.0',
'/usr/lib64/scons-2.3.0',
'/usr/lib64/python2.7/site-packages/lib32/scons',
'/usr/lib32/scons',
'/usr/local/lib32/scons',
'/usr/lib64/python2.7/site-packages/lib/python2.7/site-packages/scons',
'/usr/lib/python2.7/site-packages/scons',
'/usr/local/lib/python2.7/site-packages/scons',
'/usr/lib64/scons',
'/usr/lib64/python2.7/site-packages/RBTools-0.6-py2.7.egg',
'/usr/lib64/python27.zip',
'/usr/lib64/python2.7', #It's here, so what's the problem?
'/usr/lib64/python2.7/plat-linux2',
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old',
'/usr/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages/gtk-2.0',
'/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode']
It looks as if this isn't really a problem connected to SCons directly. You might have an alien "subprocess" module/package installed in your system. Also check out Cannot import name _args_from_interpreter_flags which seems to be related.
Based on your updated question: I tried to compile Godot on my machine (Python 2.7.3, SCons 2.3.1, Ubuntu 12.04 LTS) and it's running fine, so the problem is not related to the provided SConstruct (and its supporting build description files in subfolders). The "_scons_subprocess" module gets used only when the import of the original "subprocess.py" fails. So I suspect that the SCons start script sets up a wrong sys.path, which may happen under 64bit (see issue http://scons.tigris.org/issues/show_bug.cgi?id=2657 ).
After you added "temp.extend([os.path.join(x, 'lib64') for x in prefs])", your "print sys.path" statement shows paths like "/usr/lib64/python-exec" in its output. A Google search turned up the page http://forums.gentoo.org/viewtopic-t-985402-start-0.html for me. It describes an issue with Gentoo, where programs are installed as links to pip. Please follow the given advice and see if this fixes your problem.
It's a bug in Gentoo's scons-2.3.0 and scons-2.3.1 ebuilds (see bug report). It has been fixed in versions 2.3.1-r1 and higher.

Categories