1

I am totally new to Linux, python, and tensorflow. I am having a problem to get a data from a separate text file. Python codings are as below.

import tensorflow as tf
import numpy as np

xy=np.loadtxt('train.txt',unpack=True, dtype='float32')

x_data=xy[0:-1]
y_data=xy[-1];

print 'x',x_data
print 'y',y_data

and error messages are as below.

root@bu-R470-R420:/home/bu# source ~/tensorflow/bin/activate
tensorflow)root@bu-R470-R420:/home/bu# python -m tensorflow.linearLoad
Traceback (most recent call last):
 File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/root/tensorflow/lib/python2.7/site-packages/tensorflow/linearLoad.py", line 5, in <module>
    xy=np.loadtxt('train.txt',unpack=True, dtype='float32')
  File "/root/tensorflow/local/lib/python2.7/site-packages/numpy/lib/npyio.py", line 803, in loadtxt
    fh = iter(open(fname, 'U'))
IOError: [Errno 2] No such file or directory: 'train.txt'
(tensorflow)root@bu-R470-R420:/home/bu# 

Since i have been using Windows OS, Coding in Linux is a quite nightmare. Please help me out.

1
  • Most likely you aren't working with the correct directory. First just try to open and read the file as plain text. Focus on getting the right path. Commented Apr 27, 2016 at 3:32

1 Answer 1

3

The IOError exception you are receiving means the file train.txt doesn't exist in the relative path.

The error message clearly shows it:

IOError: [Errno 2] No such file or directory: 'train.txt'

Double check the file train.txt is present in the folder from which you are running your script, /home/bu in your case.

Sign up to request clarification or add additional context in comments.

1 Comment

Sure. please tell me how to accept your answer. It is a first time for me to visit this site. I have pressed Up Arrow already, Is there anything more to do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.