Cannot import name active_contour - python

I am studying a beginners guide on a sci-image, I successfully downloaded scikit-image via easy_install when I tried the code as shown on this site:
http://scikit-image.org/docs/dev/auto_examples/edges/plot_active_contours.html#example-edges-plot-active-contours-py
I get an error stating that from skimage.segmentation import active_contour has an error:
ImportError: cannot import name active_contour
My first solution, as what I have read on the internet is to delete the library I am using and re-installing it using pip_install however I still get the same result. Any advice on this thanks...

The active_contour_model is only avaiable in the development version of skikit-image and will (probably) be included in the skimage v.0.12 but until then you need to manually install the development version found on https://github.com/scikit-image/scikit-image.
The documentation of the stable version of skimage.segmentation is here: http://scikit-image.org/docs/stable/api/skimage.segmentation.html

Related

How to read CDF file with python on mac?

I have installed spacepy using the following command (MacOS Mojave):
pip install git+https://github.com/spacepy/spacepy.git
But I keep getting this error while trying to from spacepy import pycdf:
Exception: Cannot load CDF C library; checked . Try 'os.environ["CDF_LIB"] = library_directory' before import.
I have tried following the directions from their website, but it seems like those directions are a bit outdated.
You can do something like:
import os
os.environ["CDF_LIB"] = "~/CDF/lib" # Give the path of the cdf library
# e.g. in this case the library is in your home directory.
Before doing:
from spacepy import pycdf
Source of the error can be found on this SpacePy website.
The cdf library is available here.
Basically, you need to set up the CDF_LIB (if pycdf has a trouble finding it) before importing the module. You can read the documentation here.

Pims "Unexpected Keyword Argument" and “invalid ImageJ metadata or corrupted file”

The Context:
I'm trying to use the package trackpy for research. I'm on a Mac and I'm using (mostly) Spyder. I’m following the trackpy walkthrough (https://soft-matter.github.io/trackpy/v0.3.2/tutorial/walkthrough.html) and I’m trying to use it on a tif file. Here’s my code:
#Install trackpy (https://soft-matter.github.io/trackpy/v0.3.2/installation.html)
!conda update conda --yes
!conda install -c conda-forge trackpy --yes
#Use trackpy (trackpy walkthrough: https://soft-matter.github.io/trackpy/v0.3.2/tutorial/walkthrough.html)
from __future__ import division, unicode_literals, print_function
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import pandas as pd
from pandas import DataFrame, Series
import pims
import trackpy as tp
#Install libtif for pims.Tiffstack, per the README (which leads to this link: http://nbviewer.jupyter.org/github/soft-matter/pims/blob/master/examples/loading%20video%20frames.ipynb)
!conda install libtiff --yes
frames = pims.TiffStack("/Users/(my username)/Documents/TSVIEW_Test_5_Grey_1.tif", as_grey=True)
The Problems: When I first wrote the code, I got the error:
TypeError: init() got an unexpected keyword argument 'as_grey'
According to the trackpy walkthrough, it should take as_grey as an argument.
However, when I restarted my computer, I got a different error message (without any code changes as far as I can tell):
/anaconda3/lib/python3.5/site-packages/tifffile/tifffile.py:2113: UserWarning: invalid ImageJ metadata or corrupted file
warnings.warn('invalid ImageJ metadata or corrupted file')
Again, I didn't change the code between restarting it.
Interestingly, when I tried this code in a different python-running software, I got the first error again. I tried it in Google Colab. The only changes I made to the code were using pip instead of conda (Colab only supports pip), downloading the additional dependencies needed for pip per the trackpy install page (https://soft-matter.github.io/trackpy/v0.3.2/installation.html), and uploading the file to Colab per the 'External data: Drive, Sheets, and Cloud Storage' Colab guide.
Things I've tried:
I’ve researched both problems. For the first, I found a page that asked the same problem (pims.Video parameter issue in Spyder), but the only solution provided is "an installation issue" where certain modules are "from the wrong source.” If this is right (is it?), what does it mean? How can I install the modules from the right source?
For the second, I found from the pims website that pims is based on the the tifffile dependency (http://soft-matter.github.io/pims/v0.4/tiff_stack.html). I then found the code that brought the error message (line 2415 from the tifffile.py page https://github.com/scikit-image/scikit-image/blob/master/skimage/external/tifffile/tifffile.py), but I still don’t know how to solve it.
How can I solve these errors?

Python ImportError - NUMPY MKL

I keep getting this error whenever I try running this code, if I can get some insight in what is going on that would be a great help, since I'm pretty new to this coding environment I would really appreciate some help. The code is this:
File "C:\Users\user\Desktop\Python\pythonsimulation.py", line 6, in
from scipy import *
File "C:\Python34\lib\site-packages\scipy__init__.py", line 61, in
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
Am I missing some package or module that python requires in order to run the code?
Reason:
This error indicates that numpy is missing NUMPY_MKL. This usually happens when you have installed scipy from .whl (Pre-compiled File). To resolve this.
Solution:
Download numpy+MKL wheel(.whl) from following link and install using pip.
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
If you are using Jupyter, try restarting the kernel. please click Restart in Kernel menu.
Actually, there is no problem. Just need to restart the Jupyter and you will see it is working well.

import pandas library results in error: ImportError: cannot import name Counter

I am trying to create a dataFrame in python and the only way I have found so far is to use the pandas library.
import pandas as pd
newfilename = pd.read_csv("filename.csv")
However, when I try to excute this code, I am getting an error which says:
ImportError: cannot import name Counter
I googled and found that in python 2.6 and older versions, this error is common and they said I should install backport_collections : 0.1 to solve this issue like is explained in the below page:
https://pypi.python.org/pypi/backport_collections/0.1
However, I have no experience in doing it in the unix virtual machine.
It seems that I have to download the package "backport_collections-0.1.tar.gz" and after that I dont know how to install it or in which directory to install it.
After installation I need to import counter as follows:
from backport_collections import Counter
Please advise me on how to install this package "backport_collections-0.1.tar.gz" as I am completely new to python.

can't import pyd file from scipy

trying to import scipy.interpolate but it can’t import _fblas.pyd. It keeps throwing the following error
File "C:\cygwin64\lib\python2.7\site-packages\scipy/linalg/blas.py", line 155, in <module>
from scipy.linalg import _fblas
ImportError: cannot import name _fblas
My online research suggested that this is because I had the wrong version of numpy installed, and I need to install numpy+mkl. So I uninstalled the version I had and pip installed numpy 1.10.4, which includes mkl.
This did not fix the original problem with _flbas.pyd.
I would reinstall scipy but I can't remember where I got the version I have, and when I pip install scipy 0.17.1.tar.gz it throws an error saying that it has no blas resources, which are necessary. I've also tried to download it from here: https://github.com/scipy/scipy/releases, but they don't include _fblas.pyd in the first place.
I’m not sure where to go from here. I'm not even entirely sure why it won't import the _fblas.pyd file.
This looks like you tried to manually comply to your needed packages. Even though I take my hat off at your effort, keep in mind that this is not an simple task at all.
I might also add that this kind of work is not meant for a developer ("the person who writes the code"), but a full time maintainer. Specially with your particular Cygwin environment
So, what can you do? Alternatively, you can use one of Continuum's mkl-ready python-and-many-tools-including-mkl+scipy distribution or Enthought's Canopy. Hopefully, this will avoid you lots of hours of staring at the screen wondering what's wrong

Categories