1

I have files with code that is formatted for windows. when I try to run them on linux machine i have problem with file encodings. Can anybody suggest a solution for this

on Windows when I run I get -

This was return from redis
Exception in thread Thread-3:
Traceback (most recent call last):
 File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
 File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/bsingh/python_files/lib/Site.py", line 85, in monitor
self.update1()
File "/home/bsingh/python_files/lib/Site.py", line 78, in update1
for entry in new_pastes[::-1]:
TypeError: 'NoneType' object has no attribute '__getitem__'
8
  • Can you please put your exact error in the question? Commented Jun 17, 2015 at 6:49
  • when I do python analyse_tweet.py It doesnt print anything and goes on a wait. I dont get an error but I also dont get the results Commented Jun 17, 2015 at 6:51
  • Why do you think that's a problem with file encodings? Commented Jun 17, 2015 at 6:54
  • it appears that the files i have committed are formatted for Windows beacuse on windows machine they work perfectly Commented Jun 17, 2015 at 6:55
  • I am not sure if your linux system supports this, but did you do dos2unix <filename> ? And are you using os in your script? If so, are you doing anything specific to windows? Commented Jun 17, 2015 at 6:56

2 Answers 2

1

You should try -

dos2unix <filename> 

To convert files created in windows to unix format. Reference

Please note dos2unix, is not python code conversion, it would convert dos characters to unix equivalent.

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

Comments

1

if you think this is a problem about file encodings. maybe you should add

# -*- coding: utf-8 -*-

or

# coding: utf-8

in the head(line 1 or line 2) of any python script file.

2 Comments

I should add this on all the files that I want to run on linux machine ??
The config just make all you encoding set is fixed to UTF-8

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.