Cannot load scikit-learn - python

When I try to import sklearn, I get the following error message:
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
(In English: The specified module was not found)
I'm working on Windows 10, 64-Bit. I'm using Python 3.6.1. (and no other version), Anaconda and PyCharm. I installed scikit-learn using
conda install scikit-learn
and I can find it in
conda list
as well as in File | Settings | Project Interpreter with version 0.19.1. I also have numpy 1.13.3 and scipy 1.0.0.
I know this error message has been discussed multiple, but none of these discussions could help me ...
I tried uninstalling and re-installing numpy, scipy and scikit-learn. I also tried installing scikit-learn using pip.
If I randomly try to load other packages, that are in my conda list, they all work perfectly fine, but not scikit-learn.
I don't even know where my error is. Can anyone give me a hint in the right direction, or a suggestion what I could try?
Thanks!

Have you tried to import sklearn directly from a Python interpreter ?
Also, try to check in your Project Settings that sklearn is recognized as a package of the Python interpreter associated (Settings --> Project --> Project Interpreter)

I was having the same problem. The version of Sklearn was 0.14.1 and when I did a py -3.6 -m pip install --upgrade scipy I got the message that the version I have is current. But sklearn was not recognized from within Jupyter or from the Idle environment. So I went to the site https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn, downloaded the correct .whl file, and installed it. Now I can import it.
By the way, to use scikit-learn, you will need both numpy and mkl.

Related

Installing Tensorflow on mac m1

I am using PyCharm and in the Python Interpreter I install my packages. In other words
In Pycharm: from Python 3.9 venv --> Interpreter Settings --> Install Package: Tensorflow (+) --> Search for Package --> Install
I almost got anything I want (numpy, scipy, pandas, even torch!). However, I tried to install Tensorflow and I get the following ERROR:
ERROR: Could not find a version that satisfies the requirement tensorflow
ERROR: No matching distribution found for tensorflow
So, I tried using the shell and it is already installed in my pip list with the version 2.4.0 as of today.
Since I am using a virtual env in PyCharm, is there a way that I can solve the error and have the package installed? OR how can I migrate the installed packages from my pip to this venv?
If you are an M1 user you would already know that working on apps is a headache with the new silicon apple Mac.
I look forward to some help and suggestions.
Thanks!
Basically, at the time of posting this issue, tensorflow does not support Python 3.9 and only works for 3.8.
Further details are provided #47151

How to update the version of pandas that I'm using in Visual Studio code. I think my python installs are setup improperly

I've scoured the internet without much luck of finding how to fix what I'm doing wrong. I think I have all the pieces to the puzzle and know what is wrong but I just don't know what I need to do to fix it.
I'm starting to think I have two installs of python and I'm not updating the install that's being used in VS code and the python install that I have updated is not properly setup in VS code. I have anaconda downloaded but I think the VS code python extension is the only one that is set up properly. If I use the anaconda prompt and follow what a number of posts/solutions detail
import pandas as pd
pd.__version__
I get 1.1.3 which I believe I updated the other day when trying to fix my issue. However, if I use the terminal in VS code and do the same thing, I get 1.0.5 (which is the pandas version that produces the issue I am dealing with... it messes with dates when plotting pandas df). I'm guessing this has something do to with anaconda not being set to PATH and VS code is using the extension instead of the anaconda download. To further back this up, if I select
Python 3.7.9 64-bit (conda) interpreter instead of Python 3.7.9 64-bit
and run code that typically works on the non-conda interpreter, I get the following:
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Users\user
\anaconda3\python.exe"
* The NumPy version is: "1.19.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
If what I suspect is the issue, then I'm a bit confused how I've been able to import and use packages such as pandas, matplotlib, and Numpy when using the non-conda interpreter.
Would someone be able to explain and steer me in the right direction?
The reason for getting two different versions of "pandas" is that the Python interpreter you are using is different. The "Python 3.7.9 64-bit" you use is the python interpreter (global environment) that you downloaded and installed, and the "Python 3.7.9 64-bit (conda)" is the Python interpreter that comes with Anaconda (conda environment).
According to the terminal information you provided, there is no dependent package "numpy" of "pandas" in a non-conda environment. It is recommended that you install the module "numpy" (pip install numpy). Usually, when the module "pandas" is installed, the terminal will automatically install the dependencies it needs. Therefore, you could also reinstall "pandas" in the VSCode global environment.
If you want to specify a certain version of the module "pandas", you could use "pip install pandas==1.1.3" to install version 1.1.3.

Installing XLWings with Anaconda with Packages

I have a fresh Anaconda installation (2019.07) for Windows with xlwings version 0.15.8. When I run from RunPython in VBA and try to import numpy I get the following error:
ImportError: DLL load failed: The specified module could not be found.
However when I go to my conda prompt and run python I can import numpy without issue.
The latest version seems to have added a Conda Base configuration variable but I haven't had luck getting it work. The only way I can get it to find pythonw is to use Interpreter variable instead of Conda Base, but that does not find the packages like numpy above.
How do I set the xlwings.conf properly to find my conda install C:\anaconda3, all of the conda packages (like numpy) and my src tree C:\[blah]\src in Windows?
As of Nov 19, 2020
Installing Python using Anaconda version 2020.11.
xlwings comes pre-installed with version 0.20.8 for Windows 32/64 bit and Mac osx-64
This might help anyone else struggling to get set up.

TensorFlow installation results in ImportError: No module named tensorflow

I'm trying to get TensorFlow to work on my Mac (OSX El Capitan 10.11.2). I tried the pip install from the setup guide and also followed the instructions in the accepted answer here.
In both cases I am able to successfully activate the virtualenv and my prompt changes to tensorflow. Python works fine, I'm able to do simple computations on the command line. But when I try to import tensorflow:
import tensorflow as tf
I repeatedly get this error:
ImportError: No module named tensorflow
Any help would be appreciated.
I had the issue reported in the original question. Python worked fine, I followed the installation steps on the Tensforflow website, and got "No module named tensorflow."
Re-installing python via brew, and re-installing pip as a result, fixed it. I didn't need to uninstall anything, just the line below along with the normal pip install from the tensorflow installation document afterwards:
brew install python

Scikit-learn version ambiguity

I have anaconda 2.7 for Windows 7, 64 bit. I wanted to upgrade my scikit-learn version from 0.15 to 0.16.1 but I had some connection problems so I could not follow the guide here: http://scikit-learn.org/dev/install.html#id1 (I tried several times...) . So I used scikit-learn-0.16.1.win-amd64-py2.7.exe (md5) downloaded from https://pypi.python.org/pypi/scikit-learn/0.16.1.
When I go to check the version of scikit learn in spider using the code:
import sklearn
sklearn.__version__
I read the exact version, that is: '0.16.1' but if I try to use:
from sklearn import cross_validation
I have the following error:
ImportError: cannot import name check_arrays
that means that actually, it doesn't use the version 0.16.1!
So how can I solve? I tried to unistall and install again but it is the same. Since I have network restriction I can't access to the web using the command windows.
Thank you
You can't upgrade a package installed with anaconda with pip. Just do conda update scikit-learn, see the installation docs

Categories

Resources