Can't import sklearn on Python 3.6 - python

I'm trying to import the skit-learn library but it´s generate this error:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
import sklearn
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\base.py", line 12, in <module>
from .utils.fixes import signature
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
from ..utils.fixes import signature
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\fixes.py", line 144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\__init__.py", line 114, in <module>
from .isolve import *
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
from . import _iterative
ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.
Someone could say what's happening, I'm completely lost with this.
Thanks a lot

Sorry if this seems obvious but there's not a lot of information given here so i can't tell what you already tried or not.
This package isn't included in the standard library so you'd have to have downloaded/installed it before importing did you follow the instructions on the library's website? http://scikit-learn.org/stable/install.html
Edit: found a similar issue DLL Load Failed: The specified module could not be found [Python]

I was looking into this not too long ago, I think script on windows is a little tricky. SciPy has directions to an installer on their webpage https://www.scipy.org/install.html. If you've installed python specifically for this project I would go and get anaconda. You can uninstall the python you have or just tell anaconda to replace the path during installation.
Good luck!

Alright guys. I finally could solve the problem.
I don't know why, but I uninstall NumPy, SciPy and Scikit-Learn and install again using the binary files from here:
link
And it's work. All these libraries are working correctly.
Something was running wrong installing from pip.
Well, I think it's case closed. Thank you #Hopeful_O, #juanpa.arrivillaga, #abccd and #shadefc09 for the help.

Related

pip commands return a TypeError

I needed to install hashlib for one of my projects, and used easy_install hashlib (as was stated by this Stack Exchange post) to do so. However, right after I installed this package, I haven't been able to use pip at all. Whenever I type a command with pip (like pip install), I get the following error message:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 37, in <module>
import email.parser
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/feedparser.py", line 27, in <module>
from email import message
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 16, in <module>
import email.charset
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/charset.py", line 13, in <module>
import email.base64mime
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
import hashlib as _hashlib
File "build/bdist.macosx-10.13-intel/egg/hashlib.py", line 115, in <module>
"""
TypeError: 'frozenset' object is not callable
This also now occurs when I'm using easy_install- same error. I'm also not able to uninstall pip and reinstall- any command with pip results in the error above. Even executing
pip --version yields the same error. I know it's something to do with the hashlib package, but I'm not sure how to delete it and reinstall without messing up my entire Python configurations. My hypothesis is that the version of hashlib I installed is either too old or too new for my Python 2.7, and doesn't play well with it.
Does anyone know what exactly is going on behind the scenes here in this stack trace, and how I can fix pip?
Is the best thing to do to literally go in and delete hashlib.py from my lib/python2.7 folder?
So, this doesn't solve the issue with hashlib, but it does get you a working pip again: literally download and reinstall Python 2.7 all over again from the source. If anyone comes up with a better, more elegant solution for fixing pip, I am all for it.
However, at least I can use pip again...

Numpy - ImportError: cannot import name shares_memory

I'm going to preface this by saying that I'm relatively new to Python and so please forgive me if I have difficulty understanding something.
I've recently been trying to install OpenCV on my computer following the "Installing OpenCV from prebuilt binaries" instructions found here:
http://docs.opencv.org/3.1.0/d5/de5/tutorial_py_setup_in_windows.html#gsc.tab=0
I initially tried to install OpenCV by itself, as I already had Python 3.5 and a working version of numpy. However, my attempts to import cv2 failed, and I eventually decided to uninstall Python and follow all the steps listed on the website. However, I now have this error when I try import numpy:
Traceback (most recent call last):
File "C:/PythonProgramming/SLIC/src/SLICAlgorithm.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 20, in <module>
import function_base
File "C:\Python27\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Process finished with exit code 1
Other people online seem to have no problem with these instructions, or at least not with numpy. What does this error mean, and what can I do to fix it? I have a 64-bit version of Windows 10 and am working in PyCharm. All help you can provide would be much appreciated.
same problem, the following fix worked for me
pip install -I numpy --force-reinstall

PYTHON DLL load failed

I usually code in Matlab but I found a nice piece of PYTHON code that I would like to use. However having downloaded the package it is proving difficult to run. I'm getting the following error:
Traceback (most recent call last):
File "C:\launch.py", line 29, in <module>
from src.smcsquare import SMCsquare
File "C:\src\smcsquare.py", line 32, in <module>
from scipy.stats import norm
File "C:\Python34\lib\site-packages\scipy\stats\__init__.py", line 338, in <module>
from .stats import *
File "C:\Python34\lib\site-packages\scipy\stats\stats.py", line 184, in <module>
import scipy.special as special
File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 586, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
The _ufuncs.pyd is there in the C:\Python34\lib\site-packages\scipy\special\ directory. I tried adding this to my PYTHONPATH but it made no difference. I have also tried so dll fixers but these have not helped.
Has anyone encountered this and did you find a solution?
As other have said, make sure your .whl file matches the version and 32/64bit of the python distribution you're using.
Next, the problem I was having was I forgot to download and install the extra "numpy+mkl" package per the instruction: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
So for me it was numpy-1.11.0+mkl-cp35-cp35m-win_amd64.whl, which I downloaded and then:
python -m pip install numpy-1.11.0+mkl-cp35-cp35m-win_amd64.whl
I had already installed the regular numpy package via pip, but I just installed this one over it and everything started working and has been fine so far.

Python requests_ntlm import error

Hello i am receiving the following error when i try to import the requests_ntlm package. I installed the package with easy_install requests-ntlm. I am trying to use this library so that I can log onto an aspx.net webserver with www-authenticate: negotatiate NTLM response header using python. Appreciate any help solving this issue let me know if I need to provide more information. Thanks!
Traceback (most recent call last):
File "SHS.py", line 2, in <module>
from requests_ntlm import HttpNtlmAuth
File "build\bdist.win-amd64\egg\requests_ntlm\__init__.py", line 1, in <module
>
File "build\bdist.win-amd64\egg\requests_ntlm\requests_ntlm.py", line 4, in <m
odule>
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\__init_
_.py", line 2, in <module>
from . import HTTPNtlmAuthHandler # noqa
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\HTTPNtl
mAuthHandler.py", line 20, in <module>
from . import ntlm
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\ntlm.py
", line 25, in <module>
from . import des
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des.py"
, line 19, in <module>
from . import des_c
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des_c.p
y", line 19, in <module>
from .des_data import des_SPtrans, des_skb
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des_dat
a.py", line 25, in <module>
U32(0x00820200), U32(0x00020000), U32(0x80800000), U32(0x80820200),
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\U32.py"
, line 32, in __init__
value = six.byte2int(value)
File "C:\python27\lib\site-packages\six-1.8.0-py2.7.egg\six.py", line 605, in
byte2int
return ord(bs[0])
TypeError: 'long' object is not subscriptable
Sorry about that! Package maintainer here.
It looks like it was a problem with Windows. I just released v1.0.2 which fixes this and added Appveyor support to catch these problems in future.
Edit: On a Windows PC you probably hit the error with pip HttpNtlmAuth to fix it you will need to pip requests_ntlm to get v1.0.2.
Not an answer, however:
I've opened a GitHub issue for this bug: https://github.com/trustrachel/python-ntlm3/issues/6 .
Currently the workaround is to use requests-ntlm version 0.0.3.
I also struggled with this problem when I am on
Python 3.7.0
requests-ntlm==1.1.0
Finally SOLVED with different version
Python 3.7.0
requests-ntlm==0.1.0
I had the same issue while connecting to SharePoint using SSO(Single Sign-On)
The following statement solved my problem:
pip install requests_ntlm

ImportError: Module use of python26.dll conflicts with this version of Python

I use Python 3.2.3
Tonight I tried to install requests from http://docs.python-requests.org/en/latest/ by pip and easy_install, but it doesn't work. I have error when trying to import it. So I decided to use standard library urllib.request and see this error again
That is the traceback:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\__init__.py", line 52, in <module>
from . import utils
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\utils.py", line 12, in <module>
import cgi
File "E:\Python32\lib\cgi.py", line 38, in <module>
from email.parser import FeedParser
File "E:\Python32\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "E:\Python32\lib\email\feedparser.py", line 27, in <module>
from email import message
File "E:\Python32\lib\email\message.py", line 17, in <module>
from email import utils
File "E:\Python32\lib\email\utils.py", line 28, in <module>
import socket
File "E:\Python32\lib\socket.py", line 46, in <module>
import _socket
ImportError: Module use of python26.dll conflicts with this version of Python.
So how can I fix this?
UPD: Solved. It was bug in SublimeREPL, reinstalled that package.
I had a similar problem when I was using PythonXY. The Spyder was not loading and it turns out another software OpenCAD had installed Python2.6 version and that was not letting my Python27.dll to not work. After uninstalling OpenCAD, I was able to run the software.
I was able to troubleshoot by first searching for python26.dll and found that this file was located in the OpenCAD folder location and that made me realize that this software was causing the issue.

Categories

Resources