Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on preamble import #1

Closed
saptak opened this issue Jun 2, 2016 · 16 comments
Closed

Error on preamble import #1

saptak opened this issue Jun 2, 2016 · 16 comments

Comments

@saptak
Copy link

saptak commented Jun 2, 2016

I am getting the following error:

from preamble import *

%matplotlib inline

ImportError Traceback (most recent call last)
in ()
----> 1 from preamble import *
2 get_ipython().magic(u'matplotlib inline')

/Users/ssen/Box Sync/projects/introduction_to_ml_with_python/preamble.py in ()
2 import numpy as np
3 import matplotlib.pyplot as plt
----> 4 import mglearn
5
6 set_matplotlib_formats('pdf', 'png')

/Users/ssen/Box Sync/projects/introduction_to_ml_with_python/mglearn/init.pyc in ()
----> 1 from . import plots
2 from . import tools
3 from .plots import cm3, cm2
4
5 all = ['tools', 'plots', 'cm3', 'cm2']

/Users/ssen/Box Sync/projects/introduction_to_ml_with_python/mglearn/plots.py in ()
9 plot_single_hidden_layer_graph,
10 plot_two_hidden_layer_graph)
---> 11 from .plot_linear_regression import plot_linear_regression_wave
12 from .plot_tree_nonmonotonous import plot_tree_not_monotone
13 from .plot_scaling import plot_scaling

/Users/ssen/Box Sync/projects/introduction_to_ml_with_python/mglearn/plot_linear_regression.py in ()
3
4 from sklearn.linear_model import LinearRegression
----> 5 from sklearn.model_selection import train_test_split
6 from .datasets import make_wave
7

ImportError: No module named model_selection

@amueller
Copy link
Owner

amueller commented Jun 2, 2016

As the readme says, you need the development version of scikit-learn.
It will be released before the book is published.

@saptak
Copy link
Author

saptak commented Jun 2, 2016

Thank you amueller for the quick reply. I upgraded to the development version. I double checked as below but get the same error:

pip show scikit-learn

Metadata-Version: 1.1
Name: scikit-learn
Version: 0.18.dev0
Summary: A set of python modules for machine learning and data mining
Home-page: http://scikit-learn.org
Author: Andreas Mueller
Author-email: amueller@ais.uni-bonn.de
License: new BSD
Location: /Users/ssen/anaconda/envs/dato-env/lib/python2.7/site-packages

@amueller
Copy link
Owner

amueller commented Jun 2, 2016

if you run import sklearn; print(sklearn.__version__), what do you get?

@saptak
Copy link
Author

saptak commented Jun 2, 2016

Somehow, I am still getting

import sklearn; print(sklearn.version)

0.17.1

On Thu, Jun 2, 2016 at 12:16 PM, Andreas Mueller notifications@github.com
wrote:

if you run import sklearn; print(sklearn.version), what do you get?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AEZ0CXz1kBjzHRet8eINDMlgQO17I8KYks5qHywCgaJpZM4Isz1r
.

@amueller
Copy link
Owner

amueller commented Jun 2, 2016

your pip and the python you are using belong to different python environments.

@saptak
Copy link
Author

saptak commented Jun 2, 2016

Looks like they are using the same python environment:

(dato-env)HW12341:introduction_to_ml_with_python ssen$ which pip

/Users/ssen/anaconda/envs/dato-env/bin/pip

(dato-env)HW12341:introduction_to_ml_with_python ssen$ which python

/Users/ssen/anaconda/envs/dato-env/bin/python

(dato-env)HW12341:introduction_to_ml_with_python ssen$ which ipython

/Users/ssen/anaconda/envs/dato-env/bin/ipython

On Thu, Jun 2, 2016 at 12:30 PM, Andreas Mueller notifications@github.com
wrote:

your pip and the python you are using belong to different python
environments.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AEZ0CVYVH01iWT4EUzbe7JzjX04ovYmnks5qHy9BgaJpZM4Isz1r
.

@amueller
Copy link
Owner

amueller commented Jun 2, 2016

If you install with conda, you shouldn't upgrade with pip. If you did that,
remove the scikit-learn folder and reinstall will pip.

Sent from phone. Please excuse spelling and brevity.
On Jun 2, 2016 5:48 PM, "Saptak Sen" notifications@github.com wrote:

Looks like they are using the same python environment:

(dato-env)HW12341:introduction_to_ml_with_python ssen$ which pip

/Users/ssen/anaconda/envs/dato-env/bin/pip

(dato-env)HW12341:introduction_to_ml_with_python ssen$ which python

/Users/ssen/anaconda/envs/dato-env/bin/python

(dato-env)HW12341:introduction_to_ml_with_python ssen$ which ipython

/Users/ssen/anaconda/envs/dato-env/bin/ipython

On Thu, Jun 2, 2016 at 12:30 PM, Andreas Mueller <notifications@github.com

wrote:

your pip and the python you are using belong to different python
environments.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<
#1 (comment)
,
or mute the thread
<
https://github.com/notifications/unsubscribe/AEZ0CVYVH01iWT4EUzbe7JzjX04ovYmnks5qHy9BgaJpZM4Isz1r

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAbcFuBDFyNWZeGjwNrP3RRvqJ5Yh7Xkks5qH0-ugaJpZM4Isz1r
.

@saptak
Copy link
Author

saptak commented Jun 2, 2016

Thanks that solved it

@saptak saptak closed this as completed Jun 2, 2016
amueller pushed a commit that referenced this issue Dec 8, 2016
@Amirosimani
Copy link

Im also getting the error on: from preamble import *

I removed scikit-learn and re-installed with pip. running import sklearn; print(sklearn.version) , I get: 0.18.1
any suggestions how to fix it?

@amueller
Copy link
Owner

amueller commented Feb 12, 2017 via email

@Amirosimani
Copy link

ImportError Traceback (most recent call last)
in ()
1 import mglearn
2 get_ipython().magic('matplotlib inline')
----> 3 from preamble import *
4
5 X, y = mglearn.datasets.make_forge()

ImportError: No module named 'preamble'

@amueller
Copy link
Owner

How are you running the notebooks? This repository contains the notebooks, and along with the notebooks a file called preamble.py that is imported here. Make sure that this file is present when running the notebook.

@aduk4u
Copy link

aduk4u commented Nov 21, 2017

Hello guys, I need help. I get error when i try to execute this command;
mglearn.plots.plot_two_hidden_layer_graph()

I always have the following error tracebacks


ModuleNotFoundError Traceback (most recent call last)
in ()
1 import mglearn
----> 2 mglearn.plots.plot_two_hidden_layer_graph()

C:\Users\SK.ipython\mglearn\plot_nn_graphs.py in plot_two_hidden_layer_graph()
65
66 def plot_two_hidden_layer_graph():
---> 67 import graphviz
68 nn_graph = graphviz.Digraph(node_attr={'shape': 'circle', 'fixedsize': 'True'},
69 graph_attr={'rankdir': 'LR', 'splines': 'line'})

ModuleNotFoundError: No module named 'graphviz

How can i fix it. I am running Notebook on windows

@amueller
Copy link
Owner

@aduk4u this sounds like an unrelated issue, right? If you're using conda, you can conda install graphviz-python graphviz as described in the readme: https://github.com/amueller/introduction_to_ml_with_python#installing-packages-with-conda

If you're not using conda, you can install the required python library with pip install graphviz but installing the supporting executable is more tricky. This function will only reproduce the figure you can see in the book, by the way, so it's not that important.

@aduk4u
Copy link

aduk4u commented Nov 24, 2017 via email

@amueller
Copy link
Owner

@aduk4u Sorry I can't help you with that.

Repository owner locked and limited conversation to collaborators Nov 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants