2

I have installed tpot machine learning library after following all the steps given here: http://epistasislab.github.io/tpot/installing/

When i look at pip3 list, i could see the tpot installed. enter image description here

The below is my simple source code [https://github.com/EpistasisLab/tpot]:

from tpot import TPOTClassifier
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target,
                                                    train_size=0.75, test_size=0.25)

tpot = TPOTClassifier(generations=5, population_size=20, verbosity=2)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export('tpot_mnist_pipeline.py')

I get the below error:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from tpot import TPOTClassifier
ModuleNotFoundError: No module named 'tpot'

I am not sure what's causing this now. I checked the GitHub issues of the module and followed all solutions given there. I am using Max OS high Sierra and Python installed through Homebrew

dhanush-ai1990
  • 325
  • 4
  • 20
  • I installed the same using pip install tpot. It works for Python2.7.12 but same process doesn't get it to work for python3.6.0 – dhanush-ai1990 Jan 19 '18 at 20:37
  • A couple things to check: 1) Do you have a file in the same directory as "test.py" that is named "tpot.py"? 2) Are you sure that TPOT is installed on the same Python install that you're running this script? Try entering the Python interactive terminal (enter "python" on the command line) and try to import tpot there. – Randy Olson Mar 02 '18 at 18:52
  • No, I don't test.py in the same directory as tpot.py. I tried in command line too, still can't import tpot. – dhanush-ai1990 Mar 03 '18 at 20:53

1 Answers1

4

I had the same issue, and it appears to be due to the script being named tpot.py. Change it to something else and it should work :)

divibisan
  • 11,659
  • 11
  • 40
  • 58