SK Learn With Spyder

2,214 views
Skip to first unread message

John Faulkner

unread,
Jun 2, 2021, 7:30:20 PM6/2/21
to spyder
Hi there

I am new to Spyder / Python and trying to use the SK Learn Library with Spyder on Windows 10 however i get an Module not found error.

 I installed Python latest version first and then SK Learn using PIP which seems to be fine. I then installed Spyder which seems to have installed another version of Python under the Spyder directory. I have tried to link Spyder to the installed SK Learn library using the PythonPath manager but still the library is not recognized.

Should i be able to use the library where it is or do i need to install it in the Spyder directory ? I have also to install it in Spyder using PIP from the Spyder console but calling !PIP does not work so not sure how i would install it there ?

Any help greatly appreciated 

J

Philip Yip

unread,
Jun 3, 2021, 5:35:09 AM6/3/21
to spyder
The direct download has its own Python environment which is independent of Anaconda. It has numpy, matplotlib, pandas and scipy but none of the additional data science libraries. It also can't use pip and conda commands.

Ensure you have anaconda 2021-05 installed (the latest standalone installer).
In Windows open up the Anaconda PowerShell Prompt or in Linux open up the Terminal.
Type in:
conda update --all
This should update the Anaconda Python distribution to the latest stable version, specifically updating Python to a compatible version for Spyder 5.

Next search the anaconda and conda-forge channels for the latest Spyder release:
conda search --channel anaconda spyder
conda search --channel conda-forge spyder

At the time of writing the conda-forge channel is more up to date than the anaconda channel.
Type in:
conda install --channel conda-forge spyder=5.0.3
On my Linux and Windows 10 install not specifying the version number preferenced spyder version 4.2.5, so I had to specify 5.0.3 to begin the install.

yfprojects

unread,
Jun 3, 2021, 7:59:46 AM6/3/21
to spyder
Hello J,
Philip states how to install spyder with Anaconda which is another way of using python,  a different distribution. This doesn't use the spyder stand-alone installer found on their website. If you use Anaconda and install spyder there,  you should deinstall the spyder from the stand-alone installer.
It is possible to install packages spyder using pip but on windows using the Anaconda Python is generally the better way to go.

Kind regards
yfprojects

John Faulkner

unread,
Jun 6, 2021, 10:06:24 PM6/6/21
to spyder
Thanks for your reply - I used the Spyder install package recommended for Windows 10 so i have not used Anaconda. Is there a solution without using Anaconda dya think ?

yfprojects

unread,
Jun 7, 2021, 10:13:32 AM6/7/21
to spyder
Yes, it is possible,  but very complicated. Therefore I will first give instructions how to use Anaconda:
1. Go to anaconda.com and download the right version.
2. Start the downloaded installer and follow its instructions.
3. Start the Anaconda Navigator.
4. Launch the CMD.exe Prompt.
5. Enter `conda uninstall scikit-learn`. (optional since preinstalled)
6. Enter `conda install -c conda-forge scikit-learn`. (optional since preinstalled)
7. Install Spyder 5.0.3 using `conda install -c conda-forge spyder`.

Now how to use the standalone Spyder. First of all you will need to use the python distribution from python.org. Then:
1. Install stand-alone Spyder from their website.
2. Open the command line (cmd.exe)
3. Enter `python --version`, this should return something with "Python 3".
4. Enter `python -m pip install -U pip`.
5. Enter `pip install scikit-learn`.
6. Enter `pip install spyder-kernels==2.0.*`
7. Enter `python -c "import sys; print(sys.exec_prefix)`.
8. Remember the output. It is the path to your python installation. (Copy it or leave the window open).
9. Open Spyder.
10. Go to the Spyder preferences (Tools > Preferences)
11. Navigate to the Python interpreter tab in the preferences.
12. Choose 'Use the following Python interpreter".
13. Enter the path from step 8 into the line below  and append '/python.exe'. You can verify that this file exists by clicking on the document icon next to the entry.
14. Klick OK.
15. Restart the console/Spyder.
Reply all
Reply to author
Forward
0 new messages