ImportError: No module named datasets

2019-03-29 08:45发布

from datasets import dataset_utils ImportError: No module named datasets. when i am writing this in python sript.

import tensorflow as tf
from datasets import dataset_utils
slim = tf.contrib.slim

But i am getting error.

from datasets import dataset_utils
ImportError: No module named datasets

I found this solution How can jupyter access a new tensorflow module installed in the right path? I did the same and i have dataset packages at path anaconda/lib/python2.7/site-packages/. Still i am getting same error.

3条回答
欢心
2楼-- · 2019-03-29 09:01

It's using the datasets package in the TF-slim image models library, which is in:

git clone https://github.com/tensorflow/models/

Having done that though, in order to import the module as shown in the example on the slim image page, empty init.py have to be added to the models and models/slim directories.

查看更多
可以哭但决不认输i
3楼-- · 2019-03-29 09:06

Datasets is present in https://github.com/tensorflow/models/tree/master/slim/datasets Since 'models' are not installable from pip (at the time of writing), they are not available in python load paths by default. So either we copy them or manually add to the path. Here is how I setup env before running the code:

# git clone or wget
wget https://github.com/tensorflow/models/archive/master.zip -O models.zip 
unzip models.zip
# add it to Python PATH
export PYTHONPATH=$PYTHONPATH:$PWD/models-master/slim
# now we are good to call `python mytensorflow.py`
查看更多
叛逆
4楼-- · 2019-03-29 09:13

You can find the folder address on your device and append it to system path.

import sys  
sys.path.append(r"D:\Python35\models\slim\datasets"); import dataset_utils  

You'll need to do the same with 'nets' and 'preprocessing'

sys.path.append(r"D:\Python35\models\slim\nets"); import vgg
sys.path.append(r"D:\Python35\models\slim\preprocessing"); import vgg_preprocessing  
查看更多
登录 后发表回答