Why am I not able to import sklearn?
I downloaded Anaconda Navigator and it has scikit-learn in it. I even pip installed sklearn , numpy and scipy in Command Prompt and it shows that it has already been installed, but still when I import sklearn in Python (I use PyCharm for coding) it doesn't work. It says 'No module named sklearn'.
Your python interpretor in pycharm is probably not pointing to Anaconda's python, but to the system's default.
See this to select the correct python binary.
Problem solved! I didn't know that I was supposed to change my interpreter to Anaconda's interpreter(I am fairly new to Python). Thanks for the help!
If someone is working with via bash here are the steps :
For ubunutu :
sudo apt-get install python-sklearn
Related
I have used widely used packages(installed via pip) for a while in Jupyter notebook without any issues. I tried to do Python coding in VScode,but it somehow cannot load those packages.
I have tried changing python interpreter, but it did solve the issue. Does anyone know how to resolve this issue?
First make sure that you have the python interpreter installed on your computer. In your vscode UI you should see a terminal. You can install and upgrade pip through there if needed by using these commands:
pip install --upgrade pip
From here you should be able to import using pip commands.
Hi you can use terminal for installation.
otherwise you can anaconda iDE its very good tool and user friendly.
I have created a different environment for python 3.6.7 32-bit Windows for pyenchant. I have done pip install pyenchant. It was successfully installed. From the command prompt I am able to import the library and also run the example. But when from the same environment, I load the jupyter notebook, and try to import enchant but it gives error : ModuleNotFoundError: No module named 'enchant'. I have wasted a lot of time trying to fix it. Any leads appreciated.
Maintainer have gave up on supporting pyenchant for windows x64 + python3.5 (here).
The only thing you can do there right now is to try to build it yourself. Or maybe wait until someone steps up as a maintainer of that library.
Here is supporting doc issue for the same:
https://github.com/kivy/kivy/issues/5816
Hope it helps.
I am installing python on windows10 and trying to install the opencv and numpy extentions in the command window. I get no error installing them and it says it is successfully installed. But when I try to check the installation and import cv2 it does not recognize it and give me the error: no module named cv2.
can anybody help me with this problem? Is there something wrong in installation process or do I need to install something else?
I checked the newest version of each and used the compatible one with my system.
Thanks.
One solution could be that you have 2 versions of python. So, go to the specific python's scripts directory and run: pip install numpy
If that too doesn't work, you can find the answers to this question on Why can't I import opencv3 even though the package is installed?, as stated by #Cut7er.
I have tried the solutions given to the above stated question myself also. But, they didn't work for me. So, another thing that you could try to use is this IDE called PyCharm. It ofcourse is much more beautiful that the IDLE, but it also has an inbuilt GUI controlled installation of binaries or packages. That would make things a lot easier. I have faced a lot of issues with packages for python and this IDE made things a lot easier. You can find it on https://www.jetbrains.com/pycharm/download/#section=windows.
You can also use anaconda. But, I found it a little difficult to use since, it has similar issues.
EDIT:
Seems like you are using PyCharm. But, you are installing libraries from your command prompt. So, see the answer to: ImportError: No module named 'bottle' - PyCharm. This answer guides you through how to install a certain library through your PyCharm window itself. So,
1) Go to Files>Settings
2) Search for "Interpreter" from the searching tab. Open the interpreter
3) You can now see a plus sign on the right. A click on it will open up a section on the left.
4) In the searching tab, search for numpy or opencv. Click on whichever module you want to install. And then click on the "install package" button on the bottom left. This will install the package for you.
5) Then click save. And run your file that says import cv/cv2.
This should probably do the trick.
Hope it helps!
Is it possible that you have 2 versions of python on your machine and your native pip is pointing to the other one? (e.g. you pip install opencv which installs opencv for python 2, but you are using python 3). If this is so, then use pip3 install opencv
I removed the Anaconda version on my machine, so I just have python 3.7 installed. I removed the python interpreter(Pycharm) and installed it again and the problem got fixed somehow!
I suspect you have two versions of python and the one you're using doesn't have opencv on it, because pip pointed to the wrong one.
A pragmatic solution assuming you're using the python version with conda is to just use conda to install cv2:
conda install -c menpo opencv
A more careful solution is to figure out how to get the pip that points to the python version you're using. On linux I can check that my pip points to my python like this:
:~$ which python
/home/kpierce/anaconda3/bin/python
:~$ which pip
/home/kpierce/anaconda3/bin/pip
So you see the pip and python versions are associated. On windows I suspect you do an analogous thing on the command line like
where python
where pip
And if they don't match, you might try
where python
where pip3
to see if those match. You need to use the pip that points to the correct python version. You can view the python version by entering the python interpreter and running
import sys
sys.version
I am new to python and I am trying to make a simple stock market program using pandas to import the data. I have installed Anaconda which said that it installed pandas along with it, as well as Python 2.7. I use PyCharm as my IDE. When I run:
import pandas as pd
from pandas_datareader import data
I receive the error message
import pandas as pd
ImportError: No module named pandas
I am not sure why it is giving me this error message so any help would be greatly appreciated
When entering the command to run your file, make sure you specify which version of python you're using. For example, instead of python filename.py, use python3 filename.py or python2 filename.py
Try to install it using sudo ...
sudo pip3 install pandas
for ubuntu ... it worked got me. pip or pip3 .. as per your requirement.
You need to pip install pandas and things will work.
Your issue is that pandas is not installed locally on your computer. Luckily, this is a simple task to accomplish by opening up either a Terminal or Command Prompt (depending on your OS), and typing in the command pip install pandas. This will install pandas and you will be good to go!
The issue is that Anaconda installs a Python version of its own, and likely the Python version is Python 3. When you use PyCharm IDE as your editor, you are using another version of Python (Python2). For my Mac, Anaconda's Python is installed under /anaconda3/bin and my default Python is installed under /usr/bin/python.
I recommend you either config PyCharm to use Anaconda's Python, or use Anaconda's Jupyter your project. Jupyter is arguably a stronger tool considering that you are doing data analytics task.
Also, for Anaconda's python, you shoud use conda install pandas instead of pip install pandas to install additional packages. This is not necessary this time since it's already installed.
I have the following programs installed
python 2.7 installed
Numpy-1.6.2-python2.7
Matplotlib-1.1.1-py2.7
I believe numpy has been installed properly because when I type import numpy in python interpreter, it doesn't give me an error. I can also check the version of the numpy installed.
I am getting the following error in my code on this line
import numpy as np
"Exceptions.ImportError:No module named numpy"
Does anyone know a solution to this problem? Thanks!
in terminal:
sudo apt-get install python-numpy
Sounds like you have another version of Python installed that PyScript is seeing. Easiest solution is to not use PyScript, but you may be able to fix it by re-installing/re-configuring PyScript to make sure that it points to the same location/version of your Python27
Chances are you have multiple versions of python installed, type:
which python
in your terminal, see what's the current one.
I've same issue on Mac.
But I solve it. I have two versions of pip.Look....
MacBook-Pro:WhiteBoxSMS4-master qinyao$ which pip
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip
MacBook-Pro:WhiteBoxSMS4-master qinyao$ which pip2
/usr/local/bin/pip2
so,you need check you pip version.
Like others have mentioned you have multiple versions of python installed. Check by typing:
which python
then you can use she-bang to set your script to the version of python you can use numpy with (the one you used on your command line).
Or set your PYTHONPATH variable
I've same issue on Mac OS X.
The numpy has been installed at '/Library/Python/2.7/site-packages/numpy-override',
so import numpy works normaly.
But will fail while virtualenv actived, and with non-system preinstalled python(e.g. homebrew, or macport).
$ which python
/usr/local/bin/python
Fixed by install it again in virtualenv(which created with --no-site-packages option, or without --system-site-packages).
Pylab is part of matplotlib; so you can simply install matplotlib and you will automatically get pylab, too.