CircleCI with Python in Docker - Tests

python

#1

This is a weird error that I am facing ONLY when running Python tests in CircleCI Docker mode. They work perfectly fine when running on local Docker machine. The only difference between Docker in CircleCI and local is the Ubuntu Version (14.04-CircleCi vs 16.04-Local). Could this be the reason for this issue?

My code:

some_file = path + '/some_file_name'

for line in some_file:
  sys.stdout.write(line.replace("replace_this", 
                      variable_that_may_have_unicode_chars))

updated_file = io.open(some_file, 'r')
file_contents = updated_file.read()

This is a minimal example that throws the following error:

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe8 in position 1: ordinal not in range(128)

If I use the encoding at one place, it starts throwing errors at other places where it worked earlier.


#2

Yeah, I’d try using a base image that matches the OS you have locally. Moreover, what version of Python are you running? I’d start by checking for major version changes - you’re not running 2.x on one and 3.x on the other, by any chance?


#3

Both have python 2.7.14. CircleCI 1.0 is not compatible with Ubuntu 16.x as far as I know.


#4