I'm a newbie in Python, coming from R, and I'm not a programmer, so please be patient if my question is quite silly or trivial, but I cannot find a solution by myself.
I'm using Python 3.7 in Spyder, in a Windows 10 machine.
I'm following this tutorial, and I've understood that I need the scikit-image module.
I've learned that external package should be imported in the same environment of Spyder, so I'm installing them from Spyder:
! pip install scikit-image
And I got this:
Requirement already satisfied: scikit-image in
c:\users\me\appdata\local\programs\python\python37-32\lib\site-packages
(0.15.0) ...
Same for pillow, networkx, PyWavelets, imageio, decorator, numpy (those I suppose they're the dependencies modules). It seems I've what I need.
So I try the first command of the above mentioned tutorial, that is:
from skimage import data
But the results seems this:
Traceback (most recent call last):
File "", line 1, in
from skimage import data
File
"C:\Users\me\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\skimage__init__.py",
line 124, in
_raise_build_error(e)
File
"C:\Users\me\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\skimage__init__.py",
line 104, in _raise_build_error
%s""" % (e, msg))
ImportError: cannot import name 'geometry' from 'skimage._shared'
(C:\Users\me\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\skimage_shared__init__.py)
It seems that scikit-image has not been built correctly.
But I think that this is important:
Your install of scikit-image appears to be broken. Try re-installing
the package following the instructions at:
https://scikit-image.org/docs/stable/install.html
So I went to that link, but the standard installation is what I tried to do. What am I doing wrong?
Thanks in advance
EDIT1:
I've followed the answer, I've run this:
!pip uninstall scikit-image --yes
Uninstalling scikit-image-0.15.0:
Successfully uninstalled scikit-image-0.15.0
Then
!pip install scikit-image
And the result is that is already satisfied:
Requirement already satisfied: scikit-image in
c:\users\me\appdata\local\continuum\anaconda3\lib\site-packages
(0.15.0)
And same for:matplotlib, networkx, pillow, imageio, PyWavelets, numpy, cycler, kiwisolver, pyparsing,python-dateutil, decorator, six, setuptools
EDIT2:, done in the anaconda prompt, already some package are already satisfied, so I restarted Spyder, and sending:
from skimage import data
Gives a different error:
Traceback (most recent call last):
File "", line 1, in
from skimage import data
File
"C:\Users\me\AppData\Local\Continuum\anaconda3\Lib\site-packages\skimage__init__.py",
line 127, in
from .util.dtype import (img_as_float32,
File
"C:\Users\me\AppData\Local\Continuum\anaconda3\Lib\site-packages\skimage\util__init__.py",
line 1, in
from .dtype import (img_as_float32, img_as_float64, img_as_float,
File
"C:\Users\me\AppData\Local\Continuum\anaconda3\Lib\site-packages\skimage\util\dtype.py",
line 1, in
import numpy as np
File
"C:\Users\me\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\numpy__init__.py",
line 142, in
from . import core
File
"C:\Users\me\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\numpy\core__init__.py",
line 23, in
WinDLL(os.path.abspath(filename))
File
"C:\Users\me\AppData\Local\Continuum\anaconda3\lib\ctypes__init__.py",
line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 it's not a valid application of Win32
(the last line is translated by me) that I've searched, but despite is a rather well known problem, I cannot find a solution.
Proposed solution: creating a new (virtual) environment
From the given outputs, I would suggest creating a new environment to encapsulate all packages for your current development.
For help regarding environments together with anaconda you may want to look here or create them within the gui.
Some rational for using virtual environments in general you can find in the documentation.
In short: Environments are an easy way to have separated versions of packages for different projects and you separate your development from the system python installation, which may has different packages.
Why virtual environment in your case?
Currently, it looks like a mix of packages from your system installation, paths like
"C:\Users\me\AppData\Local\Programs\Python..."
and installations of anaconda, with paths from
"C:\Users\me\AppData\Local\Continuum\anaconda3\Lib..."
probably this causes your problem (and probably will cause some more).
Looks like something went wrong when you installed. You may need to reinstall it via:
pip uninstall scikit-image
pip install scikit-image
If there are any errors during the last step (save the output), then post it here. That will give a clue as to what's wrong.
pip uninstall scikit-image
conda install scikit-image
it seems that conda will install some other dependency packets.
And it works for me.
For me this worked:-
pip uninstall scikit-image && pip install scikit-image
Related
I am trying to get the JapaneseTokenizer working in python, but I am having trouble with one of the modules it depends on. Here is the trace of the errors I am getting:
/Users/home/PycharmProjects/SubLingo/application/tokenizerTest.py
Traceback (most recent call last):
File "/Users/home/PycharmProjects/SubLingo/application/tokenizerTest.py", line 1, in <module>
import JapaneseTokenizer
File "/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/JapaneseTokenizer/__init__.py", line 6, in <module>
from JapaneseTokenizer.jumanpp_wrapper import JumanppWrapper
File "/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/JapaneseTokenizer/jumanpp_wrapper/__init__.py", line 1, in <module>
from .jumanpp_wrapper import JumanppWrapper
File "/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/JapaneseTokenizer/jumanpp_wrapper/jumanpp_wrapper.py", line 2, in <module>
from pyknp import Jumanpp
ImportError: cannot import name 'Jumanpp' from 'pyknp' (/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/pyknp/__init__.py)
As you can see Jumanpp_wrapper is trying to import the module Jumanpp from pyknp. I have looked into the pyknp package currently installed on my machine and it does not have a module with this name. This leads me to conclude that the version of pyknp I have installed is not compatible with Jumanpp, so there must be another version available somewhere. The trouble is I install pyknp using the pip installer on my Mac, as recommended on the pyknp official site, so it should be the most current version. I'm not sure how to get an alternative version that contains the necessary module. I hope someone can point me in the right direction.
I'm a developer of the package. I kindly thank you for using my package.
I fixed bugs related to the issues here and released newer package version 1.4.
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/releases/tag/1.4
You could install/upgrade the package with pip also.
Install pip install JapaneseTokenizer / Upgrade pip install -U JapaneseTokenizer
I have been in direct contact with the developer of JapaneseTokenizer who has kindly given permission for me to repost his answer to my query:
I'm glad that you sent me a message about the issue. I read your post at StackOverflow. As other user suggested, the main issue is that pyknp package does not have juman++ module. I don't know the reason, but an author of pyknp package removed module for juman++.
The straightforward way to solve this issue is that you install pyknp package version 3 from here and install it your environment.
The main procedure is below.
remove pyknp package from your environment pip uninstall pyknp
get download pyknp package previous version. http://nlp.ist.i.kyoto-u.ac.jp/DLcounter/lime.cgi?down=http://lotus.kuee.kyoto-u.ac.jp/nl-resource/pyknp/pyknp-0.3.tar.gz&name=pyknp-0.3.tar.gz
install the pyknp=0.3 with pip install pyknp-0.3.tar.gz
From now, I revise JapaneseTokenizer package. It might take some weeks. Next time you try to install JapaneseTokenizer package, everything will be fine.
Again, thanks for giving me a message.
Best,
Kensuke Mitsuzawa
I used python xy recently with an old lib of scipy (0.15). Because I wanted to use Spherical Voronoi, I had to install a more recent version of scipy. For this I used pip and the unofficial distributions for python modules with wheel. The install worked without error messages. But now, if I try to import scipy by code, I get this error message below. I already unistalled whole python packages so far and instead installed anaconda. But the error message is still the same. I checked my registry (Windows 10) - can't find anything suspicious.
Any idea? Thank you!
test.py
1.12.1
Traceback (most recent call last):
File "test.py", line 11, in <module>
import scipy
File "C:\Users\Boss\AppData\Roaming\Python\Python27\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name NUMPY_MKL
Your scipy is built with mkl support and requires mkl support in numpy too. Download numpy from the same site you downloaded scipy (probably Christoph Gohlke's builds). Or if you are using Anaconda use Anaconda packages for both.
Updated - Your error is basically that numpy+mkl (numpy with Intel math Kernel library) so this is because when you have installed the scipy by precompiled archive, which requires numpy+mkl but installing numpy using pip won't get you that.
This problem can be easy solved by installation for numpy+mkl from whl file from - http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Old - This is due to the improper installation of numpy, I've had this error few days ago and then I had to install the numpy again. So, upgrade pip and then try installing the numpy whl again. It just worked for me.
Get it here -https://pypi.python.org/pypi/numpy
even this has almost everything - http://www.lfd.uci.edu/~gohlke/pythonlibs/
I am very new to Python and want to add Numpy and Scipy module. I think my question is very simple for you. I am using Python 3.06a.1 version. I think I already installed something called Anaconda that contains those library. When I type import scipy I get the following message:
import scipy
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import scipy
ImportError: No module named 'scipy'
also when I want to installed with command line I get the following message which means that I have it already.
localhost:~ user$ pip install scipy
Requirement already satisfied (use --upgrade to upgrade): scipy in ./anaconda/lib/python3.5/site-packages
localhost:~ user$
Please help me to fix this problem
You shouldn't have problem with scipy and numpy if you installed Anaconda. What I'm advising you may sound stupid, but I'm sure it has a good chance to solve your problem.
Relaunch Anaconda, reboot your computer, reinstall Anaconda.
Edit : also watch out to use "scipy" and not "spicy" as I just witnessed in your logs.
if you are using anaconda, try installing scipy using anaconda:
conda install scipy
Using Python 2.7 with scikit-learn 0.14 package. It runs well on some examples from the user guild expect the Linear Models.
Traceback (most recent call last):
File "E:\P\plot_ols.py", line 28, in <module>
from sklearn import datasets, linear_model
File "C:\Python27\lib\site-packages\sklearn\linear_model\__init__.py", line 12, in <module>
from .base import LinearRegression
File "C:\Python27\lib\site-packages\sklearn\linear_model\base.py", line 29, in <module>
from ..utils.sparsefuncs import mean_variance_axis0, inplace_column_scale
ImportError: cannot import name inplace_column_scale
Thank you~
I was able to fix this by going to my python folder and deleting the file:
python27\Lib\site-packages\sklearn\utils\sparsefuncs.pyd
My guess is that the problem was:
An older version of scikit-learn implemented sparsefuncs as a windows DLL
The current version implements it as a python file
If you install a new version on top of an old version it does not delete the old DLL
When you try to import, Python uses the pyd in preference to the py implementation
But the old implementation did not include this function
This suggests that there might be bigger problems caused by installing a new version and it might be wise to delete the whole sklearn directory before reinstalling the new version.
I encountered the same issue in Mac Os.
I solved it by deleting the file manually:
rm /usr/local/lib/python2.7/site-packages/sklearn/utils/sparsefuncs.so
Uninstalling scikit-learn and reinstalling it was the only option that worked for me:
pip uninstall scikit-learn
pip install scikit-learn
I solve this problem by :
pip uninstall scikit-learn
and don't forget to rm the 'sklearn' folder in the python 'site-packages'
rm -rf /path/Python-2.7.5/lib/python2.7/site-packages/sklearn/
then reinstall the package:
pip install scikit-learn
On a related note, this has been posted as a bug on the official Github page, along with some additional solutions, basically suggesting the same solutions as above. Long story short: run a make clean to get rid of the .so file.
I had the same problem. I had originally installed scikit-learn by:
sudo apt-get install python-sklearn
When none of the other solutions posted here worked, I decided to uninstall my version of scikit-learn and reinstall it:
pip2 install --user --install-option="--prefix=" -U scikit-learn
Used pip2 because I have two versions of python, so I use scikit-learn in Python 2.7
same problem happened with can not import _safe_split, have a look
http://stackoverflow.com/questions/41024001/importerror-cannot-import-name-safe-split
https://github.com/scikit-learn/scikit-learn/issues/7582
EDIT: check comment by Andreas Mueller
Hi I am new to Python and am following the Python Image Tutorial.
The following executes with no errors after installing the packages described in the tutorial
import numpy
import scipy
import pylab
import pymorph
import mahotas
from scipy import ndimage
However when I try reading an image
image = mahotas.imread('picture_file.jpg')
I get
image = mahotas.imread('image_file.jpg')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.6/dist-packages/mahotas-0.6.4-py2.6-linux-i686.egg/mahotas/init.py", line 68, in imread
raise ImportError('mahotas.imread dependends on freeimage. Could not find it. Error was: %s' % e)
ImportError: mahotas.imread dependends on freeimage. Could not find it. Error was: mahotas.freeimage: could not find libFreeImage in any of the following directories:
'/usr/local/lib/python2.6/dist-packages/mahotas-0.6.4-py2.6-linux-i686.egg/mahotas', '/lib', '/usr/lib', '/usr/local/lib', '/opt/local/lib'
I tried installing FreeImagePy and can import it with no problems but it does not help. I have tried adding to the Python path using package sys but not help either.
EDIT: I should have mentioned that all the packages except pymorph and mahotas was installed
on my linux box doing '*sudo apt-get install package_name*' while pymorph and mahotas was installed by downloading and doing 'sudo python setup.py install'.
Answer for more recent versions of mahotas
Mahotas itself does not have the functionality to read in images. imread is just a wrapper around one of 3 backends:
mahotas-imread (i.e., https://pypi.python.org/pypi/imread)
FreeImage
matplotlib (which only supports PNG & JPEG)
Thus, you need to install one of the packages above. Freeimage can be installed on Ubuntu as described below.
If you are running on Windows, you may wish to try Christoph Gohlke’s packages.
Original answer (for older versions of mahotas)
You need to install freeimage to be able to use mahotas.imread (everything else will actually work without it, it's an optional dependency). This is not a Python package per se, just a regular library.
I don't know what distribution you are in, but try looking for a freeimage package. On debian/ubuntu, you can just do:
sudo apt-get install libfreeimage3
You will have a file libfreeimage.so in /usr/lib or in a similar place and everything will work.