I have been using Atom.io to run my python codes but recently I was not able to run codes that require pyqt_fit. I could not find any packages on Atom that allow me to run pyqt. As such, I downloaded anaconda and spyder. I used homebrew to intall qt, sip, and pyqt.
In spyder, I tried to do the following:
import pyqt_fit
from pyqt_fit import plot_fit
import numpy as np
from matplotlib import pylab
x = np.arange(0,3,0.01)
y = 2*x + 4*x**2 + np.random.randn(*x.shape)
def fct(params, x):
(a0, a1, a2) = params
return a0 + a1*x + a2*x*x
fit = pyqt_fit.CurveFitting(x, y, (0,1,0), fct)
result = plot_fit.fit_evaluation(fit, x, y)
print(fit(x)) # Display the estimated values
plot_fit.plot1d(result)
pylab.show()
but I received the following errors:
runfile('/Users/Griffin/Atom/FYP Bifurcations/untitled1.py', wdir='/Users/Griffin/Atom/FYP Bifurcations')
Reloaded modules: pyqt_fit.utils, pyqt_fit.compat
Traceback (most recent call last):
File "<ipython-input-24-effdfa66efe9>", line 1, in <module>
runfile('/Users/Griffin/Atom/FYP Bifurcations/untitled1.py', wdir='/Users/Griffin/Atom/FYP Bifurcations')
File "/anaconda/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "/anaconda/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 93, in execfile
builtins.execfile(filename, *where)
File "/Users/Griffin/Atom/FYP Bifurcations/untitled1.py", line 9, in <module>
import pyqt_fit
File "pyqt_fit/__init__.py", line 14, in <module>
from . import functions, residuals
File "pyqt_fit/functions/__init__.py", line 6, in <module>
from .. import loader
File "pyqt_fit/loader.py", line 3, in <module>
from path import path
ImportError: cannot import name path
Does it have anything to do with where I place the pyqt_fit folders?
Thanks in advance!
According to the PyQt-Fit requirements file, the path.py package is a dependency. However, the PyQt-Fit package has not been updated since 2015-02-11, and there have been incompatible changes made to path.py which it has not tracked. The specific error in the question is caused by this change, which removed path as an alias for the Path class.
To fix this, you could try monkey-patching path.py like this:
# before pyqt_fit is first imported
import path
path.path = path.Path
import pyqt_fit
from pyqt_fit import plot_fit
Alternatively, you could downgrade path.py to any version >= 2.4 and < 8.0.
Related
I've installed Theano as such:
(python2) bash-3.2$ sudo pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
I'm using conda with Python 2.7. The python2 in parentheses is my conda environment. I'm trying to run the code from iGAN: https://github.com/junyanz/iGAN. I'm on OS X 10.11.6.
The error I get is ImportError: cannot import name inplace_increment. I've tried manually removing the Theano cache (as described in https://github.com/Theano/Theano/issues/5564) and the same error still arises. (I can't use theano-cache purge because it requires installing a version of scipy that clashes with the version required by OpenCV.) I've also tried uninstalling and reinstalling Theano via pip and still get the same error. Any suggestions?
Here's the context:
(python2) bash-3.2$ python iGAN_main.py
//anaconda/envs/python2/lib/python2.7/site-packages/numpy/lib/utils.py:254: FutureWarning: Numpy has detected that you (may be) writing to an array returned
by numpy.diagonal or by selecting multiple fields in a record
array. This code will likely break in the next numpy release --
see numpy.diagonal or arrays.indexing reference docs for details.
The quick fix is to make an explicit copy (e.g., do
arr.diagonal().copy() or arr[['f0','f1']].copy()).
ai = a.__array_interface__
Traceback (most recent call last):
File "iGAN_main.py", line 9, in <module>
import constrained_opt
File "/Users/.../Desktop/Code/iGAN/constrained_opt.py", line 3, in <module>
from lib.rng import np_rng
File "/Users/.../Desktop/Code/iGAN/lib/rng.py", line 2, in <module>
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/__init__.py", line 102, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/scan_module/__init__.py", line 41, in <module>
from theano.scan_module import scan_opt
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/scan_module/scan_opt.py", line 60, in <module>
from theano import tensor, scalar
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/tensor/__init__.py", line 9, in <module>
from theano.tensor.subtensor import *
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/tensor/subtensor.py", line 27, in <module>
from cutils_ext.cutils_ext import inplace_increment
ImportError: cannot import name inplace_increment
I had the same problem.
Deleting the cache manually worked.
rm -rf ~/.theano
If that doesn't help try installing from source.
python setup.py install
I am using Scipy.stats to perform distribution fits on my data. It works perfectly on my machine. But when I package my script with Python source folder, python27.dll and try to run it on another machine (where python is not installed and I do not want to also) by invoking my script like below
Path/to/Python.exe Path/to/script.py
I get the follwing error
Traceback (most recent call last):
File "test2.py", line 2, in <module>
import scipy.stats
File "C:\Users\User\Desktop\Python27\lib\site-packages\scipy\stats\__init__.py
", line 344, in <module>
from .stats import *
File "C:\Users\User\Desktop\Python27\lib\site-packages\scipy\stats\stats.py",
line 173, in <module>
import scipy.special as special
File "C:\Users\User\Desktop\Python27\lib\site-packages\scipy\special\__init__.
py", line 636, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
My script is
import sys
import scipy.stats
import numpy
dataarray= [2.45, 3.67, 1.90, 2.56, 1.78, 2.67]
desc = scipy.stats.describe(dataarray)
print desc
This occurs only on Scipy import and scipy operations, all other imports and operations work fine. My purpose is to run this script in different machines without having to actually install python
I am running a brewed Python 2.7.11 on OS X El Capitan 10.11.3. I fail to import Shapely / GEOS:
Failed `CDLL(/usr/local/lib/libgeos_c.dylib)`
Failed `CDLL(/Library/Frameworks/GEOS.framework/Versions/Current/GEOS)`
Failed `CDLL(/opt/local/lib/libgeos_c.dylib)`
Traceback (most recent call last):
File "example.py", line 2, in <module>
from shapely.geometry import Point
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geometry/__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geometry/base.py", line 9, in <module>
from shapely.coords import CoordinateSequence
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/coords.py", line 8, in <module>
from shapely.geos import lgeos
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geos.py", line 92, in <module>
mode=(DEFAULT_MODE | 16))
File "/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages/shapely/geos.py", line 61, in load_dll
libname, fallbacks or []))
OSError: Could not find lib geos_c or load any of its variants ['/Library/Frameworks/GEOS.framework/Versions/Current/GEOS', '/opt/local/lib/libgeos_c.dylib'].
This error is strikingly similar to those reported here:
Python can't import shapely and
OSError geos_c could not be found when Installing Shapely. After implementing all suggestions that "did the trick" for others, I continue to get this error.
I installed geos with brew install geos today. It installed in /usr/local/Cellar/geos/3.5.0.
If I run find / -name "libgeos_c.dylib", I find three versions:
/Library/Frameworks/GEOS.framework/Versions/3/unix/lib/libgeos_c.dylib
/usr/local/Cellar/geos/3.5.0/lib/libgeos_c.dylib
/usr/local/lib/libgeos_c.dylib
Note that the last line is exactly the same path as in the first line of the error. So Python fails to import an existing file? I know it is an alias (to the file in Cellar), but would be surprised if that's the reason.
Also, $DYLD_LIBRARY_PATH and $GEOS_LIBRARY_PATH are empty at startup, but setting them to any of the following does not resolve the problem:
export DYLD_LIBRARY_PATH=/usr/local/lib
export GEOS_LIBRARY_PATH=/usr/local/Cellar/geos/3.5.0
export GEOS_LIBRARY_PATH=/usr/local/Cellar/geos/3.5.0/lib
Any insight will be tremendously welcome! This has taken me more than half of the day already...
I use the Python distribution. Python 2.7 x64 with Windows 7 SP1 x64 Ultimate.
After a conda update --all, whenever I try to import matplotlib.pyplot I get ImportError: DLL load failed: %1 is not a valid Win32 application.. Why?
Full error stack:
Traceback (most recent call last):
File "C:\svn\hw4\code\test_con.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Anaconda\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 17, in <module>
from .backend_qt5agg import NavigationToolbar2QTAgg
File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 18, in <module>
from .backend_qt5 import QtCore
File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt5.py", line 31, in <module>
from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
File "C:\Anaconda\lib\site-packages\matplotlib\backends\qt_compat.py", line 91, in <module>
from PyQt4 import QtCore, QtGui
ImportError: DLL load failed: %1 is not a valid Win32 application.
I had the same issue after running conda update anaconda. The solution that worked for me was to simply to download the latest windows installer, then uninstall and reinstall.
I suspect this is related to the pathname of your conda environment, as if you do a clean install anaconda now wants to live in C:\Users\yourname\AppData\Local\Continuum\Anaconda2, where previously it was just Anaconda (no 2). I suspect after running the upgrade scripts some things are pointing to the nonexistant (for you) "new" path.
I found that if I explicitly activate a conda environment with activate myenvname before running anything it works fine. Likewise if you you run from the "anaconda prompt" (which activates your default environment for you) it works fine. But to get my default environment to stay active from anywhere like its supposed to I had to reinstall.
Here is what worked for me:
Run conda update -f matplotlib (from the Anaconda command prompt)
This gave me a new error:
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "C:\svn\hw4\code\test_con.py", line 1, in <module>
import matplotlib.pyplot
File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "C:\Anaconda\lib\site-packages\matplotlib\colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "C:\Anaconda\lib\site-packages\matplotlib\artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "C:\Anaconda\lib\site-packages\matplotlib\transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import
Run conda update -f numpy
This gave me a new error:
Traceback (most recent call last):
File "C:\svn\hw4\code\test_con.py", line 1, in <module>
import matplotlib.pyplot
File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "C:\Anaconda\lib\site-packages\matplotlib\colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "C:\Anaconda\lib\site-packages\matplotlib\collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "C:\Anaconda\lib\site-packages\matplotlib\backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "C:\Anaconda\lib\site-packages\matplotlib\textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "C:\Anaconda\lib\site-packages\matplotlib\mathtext.py", line 63, in <module>
import matplotlib._png as _png
ImportError: DLL load failed: The specified module could not be found.
Run conda install anaconda. This rolled your system back to a stable anaconda distribtution, and solved the issue. (I guess you could skip steps 1 and 2, but I don't feel like going through it again to confirm…)
I created my very first Python program for work and I have it running in PyCharm.
The program has a GUI, it basically pops up a window, has a directory tree so the user can select a jpg file, it then binarizes the image then lets the user select the binary threshold with a slider. It also displays two other images that I perform image transformations on.
SO, my problem is that I cannot build it to an .exe at all. I've tried Py2Exe, PyInstaller, and CX_freeze. I've tried building my own .spec files in Pyinstaller, but all have no success.
I'm running 2.7.6. I initially had 64 bit Python installed so I uninstalled everything Python related and installed 32 bit Python.
Initially when I was using pyinstaller I would just get ImportError: %1 is not a valid Win32 application, however since building a .spec file now I get actual errors. I've tried using hooks (hiddenimports=["wx", "scipy", "skimage", "matplotlib", "numpy"]) to make sure all the right files are included, but still no luck.
The main error that I'm receiving right now is: File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs(scipy\special_ufuncs.c:19992) ImportError: No module named _ufuncs_cxx
I also created a smaller code below that just pops up a Wx window with a plot inside, but I receive the same error there.
Like I mentioned, I'm new to Python, and I've done a lot of reading and haven't been able to figure this out. I've spent probably 10-20 hours just trying to get it to compile correctly.
Below isn't my actual program, but a small snippet using wxPython and MatPlotLib that produces the same error.
This is the sample code:
import wx
from PIL import Image
import matplotlib
matplotlib.use("WXAgg")
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigCanvas#,NavigationToolbar2WxAgg as NavigationToolbar
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy
from scipy import interpolate
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from skimage.filter.rank import entropy
from skimage.morphology import disk
from skimage.util import img_as_ubyte
from skimage import color
from skimage import io
import skimage
from numpy import arange, sin, pi
class CanvasPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.canvas = FigCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()
def draw(self):
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)
self.axes.plot(t, s)
if __name__ == "__main__":
app = wx.PySimpleApp()
fr = wx.Frame(None, title='test')
panel = CanvasPanel(fr)
panel.draw()
fr.Show()
This is the error I receive:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstalle\loader\pyi_importers.py", line 270, in
load_module
exec(bytecode, module.__dict__)
File "C:\users\iolvera\PycharmProjects\EL and Grayscale Analyzer\build\compilertest\out00-PYZ.pyz\scipy.interpolate",line 156, in <module>
File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\users\iolvera\PycharmProjects\EL and Grayscale Analyzer\build\compilertest\out00-PYZ.pyz\scipy.interpolate.interpolate", line 12, in <module>
File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\users\iolvera\PycharmProjects\EL and Grayscale Analyzer\build\compilertest\out00-PYZ.pyz\scipy.special", line 531, in <module>
File "c:\python27_32bit\lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 409, in load_module
module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:19992)
ImportError: No module named _ufuncs_cxx
My Python Path is correct C:\Python27_32bit\ and I also have \lib\site-packages\ and \DLL included correctly.
Like I mentioned, both programs run correctly in PyCharm.
Any help would be greatly appreciated.
Thank you!
I had this problem, and I fixed it in py2exe by specifically telling it to include the offending module. So, in setup.py:
includes = ['scipy.special._ufuncs_cxx']
setup(...,
options={"py2exe":{"includes":includes}}
)
I had this happen with a couple of other SciPy modules, too, so my includes list has about six things in it.