ImportError: No module named data_utils - python

I'm extremely new to python and I'm recently trying to understand more about Machine Learning and Neural Nets
I know this is a trivial question but I seem to be having problem importing data_utils on jupyter notebook. Can anyone please help
Note: I am not using Keras, and I am following the tutorial in this video.

I was also following the video and went through the same issue, after searching for a while; Here is the link from Github tensorflow_chatbot_required_files. You can download from here and copy it to your working directory (python file directory).
Now you will be able to import both.

Based on the link that you provided for the video you are using, go to
this link and download both files into your working directory.
The files you need to download are data_utils and seq2seq_model.
But before doing this tutorial try the tensorflow tutorials found on the tensorflow website, to get you started with this library.
Also, if you are very new to python, I recommend this tutorial first.

Since you mentioned about Machine Learning and Neural Nets, I'll assume you're referring to Keras.
I'll also assume that you installed it via
pip install keras
In that case, you need to uninstall it first by running
pip uninstall keras
Then, clone it from Github, cd into its directory and run
sudo python setup.py install
More information here

I'm assuming you are using code from tensorflow's github, in that case you need to download https://github.com/tensorflow/models/blob/master/tutorials/rnn/translate/data_utils.py into your folder also.

what you are trying to do is importing a self-defined module, in order to do that do as follow:
in your case the module is called 'data_util' which contains functions that will be called later as data_util.'function name'.
let say that the data_util which is a python file (.py) is in this directory (C:/Users/xxx/modules), so all what you have to do is to run this line of code in order for python to find your modul when you call import data_util:
import sys
sys.path.append('C:/Users/xxx/modules')
import data_util

I too was using same files.
Just open seq2seq_model.py and in line 35 remove from TensorFlow and keep it just import dat_

Related

how to import proper python module on virtual environment

I have this problem, that cannot import torch and torchvision well.
Currently, I am using the virtual environment, juneon, using Anaconda.
I think I set the library path and python path properly like the first following image.
Running the python file does not matter, However, during debugging, they cannot find those modules via VSCODE. I posted the second following image I've been seeing.
What should I check in order to solve the problem?
FYI, the third image is my file tree
Please let me know what I am missing!
Thank you in advance.

Can you install a python file from git as a module?

I am currently interested in installing the following git repository:
https://github.com/CodeReclaimers/neat-python/tree/master/examples/xor.
It contains a file called visualize.py and I would love to just install and use it as a module (e.g. numpy). However, I'm not sure how if it is possible to do this and was, therefore, hoping anyone could clarify this for me.
I have tried:
pip install git+https://github.com/CodeReclaimers/neat-python/tree/master/examples/xor
Any help would be appreciated!
Edit:
I was able to clone the entire repo:
pip install git+https://github.com/CodeReclaimers/neat-python.git
Does this mean I should be able to use all the files available in this repository as a module or is there something I'm still missing? I still cannot use visualize as a module. Thanks!
If you are able to clone the library to the same directory, you can simply import the python file without pip installing as module.
For instance if the file is called myFile.py, you can call the following and the entire file is executed and functions within can be used.
import myFile
1- open directory with modules
example : c:\users\james\appdata\local\programs\python\python39\lib
2-New python file created
example : visualize.py
3- save the python file.

A script in Tensorflow (1.4.0) needs to import 'reader.py' (which is also located in tensorflow) but fails. Not sure what to do about this

Preface: I am using Python 3.6.5, Tensorflow 1.4.0, and Unity Ml-Agents v0.3
I am using tensorflow(1.4.0) along with the Unity Ml-Agents git repository. In tensorflow there is a file called saved_model_utils.py that needs to import reader.py from a different file directory within the tensorflow package. My issue is that when I run the training program it fails at the import line in saved_model_utils.py. I have tried multiple different ways of specifying a direct path to file for the import but none of them satisfied the issue. I assume there is something I don't know that is making this difficult because it doesn't make sense that tensorflow would put a faulty script in there package. Any help is appreciated!
Here is a picture of the saved_model_utils.py:
saved_model_utils.py with reader.py highlighted in the project window
Here is a picture of the terminal and error when I run the scripts:
Terminal Error
Looking at the file paths, it seems like there's inconsistency in the folder names. I tried
from tensorflow.contrib.saved_model.python.saved_model import reader
and it's working. If you look at the file path in your first image, it's "saved_model" rather than "saved_models".
Hope this can fix your problem.

logistic_sgd module, where to find it?

doing a deep learning tutorial and my python cannot find that module.
from logistic_sgd import LogisticRegression, load_data
ImportError: No module named logistic_sgd
How can i install it ?
Download and Save logistic_sgd.py from the following link:
http://deeplearning.net/tutorial/code/logistic_sgd.py
Store it in the working directory. That's it!
Actually, you should download all the code from the following link, it contains all the dependencies you need.
Here is the source code:
http://deeplearning.net/tutorial/code/
To download all the code necessary, you can go to GitHub.
Citing from: http://deeplearning.net/tutorial/
The code is available on the Deep Learning Tutorial repositories.
If you aren't familiar with Git, you can download the source code in one zip archive file from there.
are you using the Theano library, if you are, that means your project cannot find the Theano library, use
sys.path.append(r'~/TheanoDL')
to declare it at the beginning of your project, change the path of it with your Theano is in.
Note that it works for a project with a customed Theano library.(my situation)
Best luck!

No module named itk (Insighttolkit) in Python

I am novice in python and Simple_ITK both to process .mha 3D image files. I have two problems:
When ever I install ITK, I always get an error as shown below:
and somehow I install ITK It doesn't work at all having no connectivity with python. And I also tried python-insighttoolkit3 package then it shows and error of
" Can't down load Python 2.8:i386" in Ubuntu software Center. I have tried various methods to install Insight Tool Kit in Ubuntu whatever I found but most of the time I get the same error as shown in picture above.
So can anybody guide me how to install and build ITK so that no error like no module named itk found.
Now another problem is I have a .py file and it has a class in which I have to fed input externally otherwise it will consider as None. SO I tried to call the file as
import /path/to/file/xxx.py
but it gives an Syntax error: invalid syntax
so how to call class from a python file from python Console .
Now, I'm using Ubuntu 15.02. For any missing details please ask.
Thanks.
1- For what I see in the image, I see that you are trying to install ITK instead of SimpleITK. For SimpleITK it is very simple using a linux package installer, like pip or easy-install. in this link you have the instructions to install it correctly. Remember to execute the instructions as super user. Maybe it is the reason of your error ( I can't see the instruction you are writing in the console ).
2- I recommend you to read the Python tutorial for modules The fastest way is to be located first on the directory of your .py file. The sequence would be:
cd /path
import module.py

Categories

Resources