Models: When run train.py in object_detection, then "deployment" cannot be found ?

Created on 20 Jul 2017  Â·  28Comments  Â·  Source: tensorflow/models

Traceback (most recent call last):
File "train.py", line 51, in
from object_detection import trainer
File "/root/models-master/object_detection/trainer.py", line 33, in
from deployment import model_deploy
ImportError: No module named deployment

Most helpful comment

For ubuntu @metaranha

  1. If models is located at /home/tensorflow/models/
  2. Edit ~/.bashrc and puts
    export PYTHONPATH="${PYTHONPATH}:/home/tensorflow/models:/home/tensorflow/models/slim/"

For windows, @jayshah19949596

  1. Goto My Computer > Properties > Advanced System Settings > Environment Variables > New
  2. If models is located at c:\tensorflow
  3. Variable name: Type PYTHONPATH
  4. Variable value: Fill-in your c:\tensorflow\models and c:\tensorflow\models\slim directory

All 28 comments

Please follow the object detection API installation instructions, which will add the deployment module to your PYTHONPATH.

Feel free to reopen this issue if there is a bug in the installation instructions. Thanks!

Hey I am running the api on Windows .... I got the same error ... What is the command for windows the add deployment module to PYTHONPATH

Seeing the same problem right now on Ubuntu even after doing the export as per the instruction.

Here's my trace:
File "train.py", line 51, in
from object_detection import trainer
File "build/bdist.linux-x86_64/egg/object_detection/trainer.py", line 33, in
from deployment import model_deploy
ImportError: No module named deployment

For ubuntu @metaranha

  1. If models is located at /home/tensorflow/models/
  2. Edit ~/.bashrc and puts
    export PYTHONPATH="${PYTHONPATH}:/home/tensorflow/models:/home/tensorflow/models/slim/"

For windows, @jayshah19949596

  1. Goto My Computer > Properties > Advanced System Settings > Environment Variables > New
  2. If models is located at c:\tensorflow
  3. Variable name: Type PYTHONPATH
  4. Variable value: Fill-in your c:\tensorflow\models and c:\tensorflow\models\slim directory

@ninetu
Right, I've exported the correct directory, but I'm still hitting the same
snag.

On Mon, Sep 18, 2017 at 9:12 AM, ninetu notifications@github.com wrote:

For ubuntu @metaranha https://github.com/metaranha

  1. If models https://github.com/tensorflow/models is located at
    /home/tensorflow/models/
  2. Edit ~/.bashrc and puts
    export PYTHONPATH="${PYTHONPATH}:/home/tensorflow/models:/home/
    tensorflow/models/slim/"

For windows, @jayshah19949596 https://github.com/jayshah19949596

  1. Goto My Computer > Properties > Advanced System Settings >
    Environment Variables > New
  2. If models https://github.com/tensorflow/models is located at
    c:\tensorflow
  3. Variable name: Type PYTHONPATH
  4. Variable value: Fill-in your c:\tensorflow\models and
    c:\tensorflow\modelsslim directory

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/models/issues/1992#issuecomment-330214819,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEe4RL9-KyYy3Q0DtknX2_4zrl6zV0ixks5sjmw1gaJpZM4Od2ZU
.

Make sure you puts both models and models/slim ?

On Mon, Sep 18, 2017 at 8:25 PM, emilymaxima notifications@github.com
wrote:

@ninetu https://github.com/ninetu
Right, I do have the correct directory exported, but I'm still hitting the
same snag.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/models/issues/1992#issuecomment-330219159,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVuGRzytBQ2T8DVU2arzmPFilfi3lGmmks5sjm9BgaJpZM4Od2ZU
.

Yes, both are exported and I'm still seeing the same "no module named
deployment" message.

On Mon, Sep 18, 2017 at 9:30 AM, ninetu notifications@github.com wrote:

Make sure you puts both models and models/slim ?

On Mon, Sep 18, 2017 at 8:25 PM, emilymaxima notifications@github.com
wrote:

@ninetu https://github.com/ninetu
Right, I do have the correct directory exported, but I'm still hitting
the
same snag.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/tensorflow/models/issues/1992#issuecomment-330219159
,
or mute the thread
AVuGRzytBQ2T8DVU2arzmPFilfi3lGmmks5sjm9BgaJpZM4Od2ZU>
.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/models/issues/1992#issuecomment-330220755,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEe4RBJkUbYZ-nqzrn56t9R45JcU-8CTks5sjnBlgaJpZM4Od2ZU
.

Have you put it in as c:\tensorflow\models:c:\tensorflow\modelsslim in the variable value as if you try to do 2 separate PYTHONPATH one replaces the other I was having the same problem till I tried this and then opened a new cmd window. This worked for me.

I'm building on Ubuntu, but I actually did find a solution to the problem.
It's embarrassing, but c'est la vie.

On Ubuntu, you have to 'su' to root and THEN set the path. The path doesn't
get applied globally, but you need root permissions to run the script, so
the path has to be set for a root-level account before doing all of this.
Before, I had been trying to set the path as an unprivileged user, and then
escalate, but noticed the path wasn't set.

Did all that, and problem solved!

On Thu, Sep 21, 2017 at 2:50 AM, zshobbs notifications@github.com wrote:

Have you put it in as c:\tensorflow\models:c:\tensorflow\modelsslim in
the variable value as if you try to do 2 separate PYTHONPATH one replaces
the other i was having the same problem till I tried this and then opened a
new cmd window.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/models/issues/1992#issuecomment-331067926,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEe4RENGmd_G04oEkc2HE_mfi_ubNRbqks5skgc6gaJpZM4Od2ZU
.

For linux users:

protoc object_detection/protos/*.proto --python_out=.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

Solved my issue

I had the same problem.
make sure you export the right path.
namely /models/research and /models/research/slim

you can check with echo $PYTHONPATH in linux and echo %PYTHONPATH% in windows if it's set alright.
try cd-ing into those directories with absolute paths.

there is no need to run anything as root, unless you do systemwide installs with pip or somesuch.
you can put
export $PYTHONPATH:/absolute/path/to/models/research:/absolute/path/to/models/research/slim
at the end of ~/.bashrc and you won't need to type it every time.

from slim.deployment import model_deploy

For windows 7,

  1. Go to
    My Computer > Properties > Advanced System Settings > Environment Variables > New (The first button)
  2. Add
Variable name: PYTHONPATH
Variable value: c:\tensorflow\models;c:\tensorflow\models\slim

Remember, using semicolon between 2 paths.

@FalcoGer , I am running this whole thing on mac. I tried adding as you mentioned in my bash_profile file but still getting "ImportError: No module named deployment" error.

this is how my .bash_profile looks after i add the line as you mentioned.
screen shot 2018-01-16 at 12 54 44 pm

This is the error i get
screen shot 2018-01-16 at 12 56 51 pm

If useful for anyone, for pycharm users, simply set research/slim as Sources Root by right clicking the folder and find Mark Directory As can solve the problem.

This work for me in windows:

  • Copy relevant deployment files from the \modelsslim directory
  • paste it to Python\Libsite-packages directory

then run again.It will work!

As of now, the slim folder has been moved to models/research. So if [models][1] is in the /home directory, do the following to resolve the issue:

1- Open the ~/.bashrc and add the following line to the end of the file:

export PYTHONPATH="$PYTHONPATH:/home/models:/home/models/research/slim/"

3- Close the file and do source ~/.bashrc

edit ./bash_profile in Mac os

Following @CHAMOD recommendation,copy and paste deployment and nets folder.
This works for me as well.

Hi I have add the directories o my python path but am still facing the same problem

i got the same error ,
so first i copy and paste [this code]
(https://github.com/tensorflow/models/blob/master/research/slim/deployment/model_deploy.py) to 'model_deploy.py' that i made
and changed code "from deployment import model_deploy" to "import model_deploy"

I'm using anaconda in win 10. I've tried setting the env variables both it didn't work (not sure how conda handles PYTHONPATH). So I did this:

sys.path.append('C:\\tf\\models')
sys.path.append('C:\\tf\\models\\research')
sys.path.append('C:\\tf\\models\\research\\slim')

I think the slim folder changed its location (I've cloned the repo yesterday).

I was able to import from object_detection.legacy import trainer

Traceback (most recent call last):
File "train.py", line 49, in
from object_detection import trainer
File "C:\tensorflow1\models\researchobject_detectiontrainer.py", line 32, in
from object_detection.utils import variables_helper
File "C:\tensorflow1\models\researchobject_detection\utils\variables_helper.py", line 23, in
slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

how can I fix this error...???

@markhyro123 what version of Tensorflow are you using? Contrib was removed from TF version 1.15 and forward.

@markhyro123 what version of Tensorflow are you using? Contrib was removed from TF version 1.15 and forward.

My TensorFlow version is 1.9..

Traceback (most recent call last):
File "train.py", line 55, in
from object_detection.legacy import trainer
File "C:\Userssamaresh yadav\AppData\Local\Programs\Python\Python36\libsite-packagesobject_detection-0.1-py3.6.eggobject_detection\legacytrainer.py", line 34, in
from deployment import model_deploy
ModuleNotFoundError: No module named 'deployment'

how to fix this error ?

Traceback (most recent call last):
File "test.py", line 5, in
chatbot = ChatBot('Charlie')
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packages\chatterbot\chatterbot.py", line 28, in __init__
self.storage = utils.initialize_class(storage_adapter, kwargs)
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packages\chatterbot\utils.py", line 33, in initialize_class
return Class(args, *kwargs)
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packages\chatterbotstoragesql_storage.py", line 20, in __init__
super().__init__(
kwargs)
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packages\chatterbotstoragestorage_adapter.py", line 23, in __init__
'tagger_language', languages.ENG
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packages\chatterbot\tagging.py", line 26, in __init__
self.nlp = spacy.load(self.language.ISO_639_1.lower())
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packagesspacy__init__.py", line 27, in load
return util.load_model(name, *overrides)
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packagesspacy\util.py", line 134, in load_model
return load_model_from_package(name, *
overrides)
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\libsite-packagesspacy\util.py", line 154, in load_model_from_package
cls = importlib.import_module(name)
File "C:\Users\kaveri\AppData\Local\Programs\Python\Python37\lib\importlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'en'

This work for me in windows:

Copy relevant deployment and nets folder from the C:\tensorflow1\models\researchslim directory
paste it to C:\Users\user\Anaconda3\envs\tensorflow1\Libsite-packages directory

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dsindex picture dsindex  Â·  3Comments

frankkloster picture frankkloster  Â·  3Comments

sun9700 picture sun9700  Â·  3Comments

airmak picture airmak  Â·  3Comments

25b3nk picture 25b3nk  Â·  3Comments