Tpot: Cannot Import tpot python3

Created on 19 Jan 2018  路  7Comments  路  Source: 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')

Error:

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

Pip3 list shows tpot installed

skrebate (0.4)
spacy (1.8.0)
stopit (1.1.1)
tensorflow (1.2.1)
termcolor (1.1.0)
thinc (6.5.2)
toolz (0.8.2)
TPOT (0.9.2)
tqdm (4.19.4)
ujson (1.35)
update-checker (0.16)
urllib3 (1.22)
Werkzeug (0.12.2)
wheel (0.30.0)
wrapt (1.10.11)

This is mac OS , python3.6
I have posted the same in stackOverFlow too
https://stackoverflow.com/questions/48349125/cannot-import-tpot

question

Most helpful comment

There is a solution in the link

Please try python3 -m pip install tpot

All 7 comments

Hmm, weird. Could you plz let me know the pathes of your python and pip in your environment via the commands below:

which python
which pip
# or which pip3

try

which -a python
which -a pip

The first entry of the return is the path that is called if you type python/pip in your terminal (assuming you use Mac)
Then check if your pip put tpot in the right directory. The right directory is referred to in your python under $sys.path. You can check your sys.path this way:

import sys
print("\n".join(sys.path))

Also check that your .bash_profile (or .zshrc as in my case) contains

export PYTHONPATH=$PYTHONPATH:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

while the path after $PYTHONPATH: should be where tpot is. To find your tpot, start each installed python and check each sys.path returns ending with site-packages for tpot.

If it still doesn't work try to append your tpot path to $sys.path of your preferred python.

/usr/local/bin/python
/usr/local/bin/python
/usr/bin/python

/usr/local/bin/pip
/usr/local/bin/pip

/usr/local/bin/python3
/usr/local/bin/python3

/usr/local/bin/pip3
/usr/local/bin/pip3

Thats the exact output for the commands above given above for python and python3 both. Its weird that it works for python2 but not python3

All other libraries like tensorflow, keras etc.. have no issues so far.

I am still not sure what happened to python3/pip3 in your environment. Could you please provide more details about versions of pip3 and python3. Here is a link that may help. I highly suggest use conda for managing your Python environments

There is a solution in the link

Please try python3 -m pip install tpot

Hey, the issue is solved. This is the terminal output for FYI

Collecting tpot
Collecting deap>=1.0 (from tpot)
Requirement already satisfied: scikit-learn>=0.18.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tpot)
Requirement already satisfied: numpy>=1.12.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tpot)
Collecting update-checker>=0.16 (from tpot)
Using cached update_checker-0.16-py2.py3-none-any.whl
Requirement already satisfied: tqdm>=4.11.2 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tpot)
Requirement already satisfied: scipy>=0.19.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tpot)
Collecting pandas>=0.20.2 (from tpot)
Using cached pandas-0.22.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting stopit>=1.1.1 (from tpot)
Requirement already satisfied: requests>=2.3.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from update-checker>=0.16->tpot)
Requirement already satisfied: python-dateutil>=2 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from pandas>=0.20.2->tpot)
Requirement already satisfied: pytz>=2011k in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from pandas>=0.20.2->tpot)
Requirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from python-dateutil>=2->pandas>=0.20.2->tpot)
Installing collected packages: deap, update-checker, pandas, stopit, tpot
Found existing installation: pandas 0.19.2
Uninstalling pandas-0.19.2:
Successfully uninstalled pandas-0.19.2
Successfully installed deap-1.2.2 pandas-0.22.0 stopit-1.1.1 tpot-0.9.2 update-checker-0.16

Great, good to know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fferroni picture fferroni  路  4Comments

beijingtl picture beijingtl  路  4Comments

heaven00 picture heaven00  路  4Comments

KhaledSharif picture KhaledSharif  路  5Comments

crawles picture crawles  路  5Comments