# pythontex3.py does not compile very simple xelatex file

I have the following environment LinuxMint 15 (which has python2.7 and 3.3 as part of its install. I installed Texlive, Texworks, Pygments for 2.7 and 3.

Working with Texworks and creating xelatex tex file, generating pdf does not give issues.

I installed pythontex 0.11beta according to the instructions in the pdf. (a version I have been using on windows without issues).

In pythontex3.py I changed #/usr/bin/env python to /usr/bin/env python3.

Texworks generates pythontex intermediate files without showing errors. Minimal sample code (I commented even all python code and error still occurs)

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8

\documentclass{article}

% specific for pythontex:
\usepackage{fancyvrb}
\usepackage{etex}
\usepackage{etoolbox}
\usepackage{xstring}
\usepackage{pgfopts}
\usepackage{newfloat}
\usepackage{pythontex}

\begin{pycode}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#f_aut = open('myfile.txt', encoding='utf-8', mode='w')
\end{pycode}

\begin{document}
aapnootmies

% cleanup pythontex/python
\begin{pycode}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#f_aut.close()
\end{pycode}

\end{document}


The error given: This is PythonTeX v0.11beta

----  Errors and Warnings for py:default:default  ----
Traceback (most recent call last):
* PythonTeX code error.  Error line cannot be determined.
Error is likely due to system and/or PythonTeX-generated code.
File "pythontex-files-troep/py_default_default.py", line 8, in <module>
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict')
AttributeError: 'file' object has no attribute 'buffer'


I can not figure out why but to me it seems there is still a mismatch going on between python 2.7 and 3 and/or pygments (as there is no python code at all in the resulting intermediate files as I commented it out)?

-

## 1 Answer

This is a Python version issue. You are using pythontex3.py with Python 3. So Python 3-compatible temporary scripts will be assembled and executed, via python <temp script>.py. However, it looks like using python on the command line is picking up Python 2 instead of 3. If you really need 3, you might change the version picked up by the command line or use a virtualenv or similar approach.

-
I "solved"it another way: – user2263306 Jul 1 '13 at 14:17
I changed the "/usr/bin/env python" in all the pythontex...3.py files to "/usr/bin/env/python3" and I also changed the pythontex_types3.py file (011beta version) lines 306 and 308 python to python3. – user2263306 Jul 1 '13 at 14:28