Python 导入错误:没有名为数据集的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42319101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: No module named datasets
提问by ansu1234
from datasets import dataset_utils ImportError: No module named datasets. when i am writing this in python sript.
from datasets import dataset_utils ImportError: No module named datasets。当我用 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.
我找到了这个解决方案 jupyter 如何访问安装在正确路径中的新 tensorflow 模块?我做了同样的事情,我在路径 anaconda/lib/python2.7/site-packages/ 中有数据集包。我仍然遇到同样的错误。
回答by Hisham Sliman
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
回答by Thamme Gowda
Datasets is present in https://github.com/tensorflow/models/tree/master/slim/datasetsSince '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:
数据集存在于https://github.com/tensorflow/models/tree/master/slim/datasets由于“模型”无法从 pip 安装(在撰写本文时),默认情况下它们在 python 加载路径中不可用. 所以要么我们复制它们,要么手动添加到路径中。这是我在运行代码之前设置 env 的方法:
# 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`
回答by Lumi
It's using the datasets package in the TF-slim image models library, which is in:
它使用 TF-slim 图像模型库中的 datasets 包,它位于:
git clone https://github.com/tensorflow/models/
git 克隆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.
尽管如此,为了导入模块,如纤薄图像页面上的示例所示,必须将空的init.py 添加到模型和模型/纤薄目录中。