How can jupyter access a new tensorflow module installed in the right path?

偶尔善良 提交于 2019-12-11 06:05:15

问题


Where should I stick the model folder? I'm confused because python imports modules from somewhere in anaconda (e.g. import numpy), but I can also import data (e.g. file.csv) from the folder in which my jupyter notebook is saved in.

The TF-Slim image models library is not part of the core TF library. So I checked out the tensorflow/models repository as:

 cd $HOME/workspace
 git clone https://github.com/tensorflow/models/

I'm not sure what $HOME/workspace is. I'm running a ipython/jupyter notebook from users/me/workspace/ so I saved it to:

users/me/workspace/models

In jupyter, I'll write:

import tensorflow as tf
from datasets import dataset_utils
# Main slim library
slim = tf.contrib.slim

But I get an error:

ImportError: No module named datasets

Any tips? I understand that my tensorflow code is stored in '/Users/me/anaconda/lib/python2.7/site-packages/tensorflow/init.pyc' so maybe I should save the new models folder (which contains models/datasets) there?


回答1:


From the error "ImportError: No module named datasets"
It seems that no package named datasets is present. You need to install datasets package and then run your script.
Once you install it, then you can find the package present in location
"/Users/me/anaconda/lib/python2.7/site-packages/" or at the
location "/Users/me/anaconda/lib/python2.7/"

Download the package from https://pypi.python.org/pypi/dataset and install it.
This should work




回答2:


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


来源:https://stackoverflow.com/questions/39811840/how-can-jupyter-access-a-new-tensorflow-module-installed-in-the-right-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!