Questions tagged [python-2to3]

2to3 is a tool for automated Python 2 to 3 code translation. Don't use this tag to ask about differences between Python 2 and Python 3. Use the [python-3.x] and [python-2.7] tags for that.

2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle almost all code. 2to3 supporting library lib2to3 is, however, a flexible and generic library, so it is possible to write your own fixers for 2to3. lib2to3 could also be adapted to custom applications in which Python code needs to be edited automatically.

For more information, see the documentation at: http://docs.python.org/library/2to3.html

185 questions
0
votes
1 answer

Python 2 to 3 = TypeError: descriptor 'find' for 'str' objects doesn't apply to a 'bytes' object

Hello we try to convert python 2 to 3 but we are stuck with an error. Maybe someone has an idea. Thanks if episode_num is not None: episode_num = str.encode(str(episode_num), 'ascii','ignore') if…
Werner
  • 3
  • 3
0
votes
1 answer

python 2to3: How to selectively enable fixers and only do one or two of them?

I am using 2to3 to update some python2 code. Unfortunately there is some fixers I do not like: There are some fixers I do trust (like the print fixer). So I would like to only run one the fixers I trust. For Python 2to3, how do you disable all…
Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
0
votes
0 answers

make a package support python 3

the original code which only support python 2 is here link to thinkgear.py I'm trying to edit it to support python 3. the edited code is here: import sys import serial from io import BytesIO import struct from collections import…
0
votes
0 answers

Problem when upgrade package from python 2 to 3

when running in python2, i get the result like this: DEBUG:__main__:ASIC EEG Power: EEGPowerData(delta=7784, theta=7734, lowalpha=2035, highalpha=1979, lowbeta=2914, highbeta=3996, lowgamma=1944, midgamma=1847 when running in python3, the result is…
0
votes
0 answers

Problem when edit a package from python 2 to 3

I am working on editing this package from python 2 to python 3 because I need use KivyMD, which only support python3. source code can be found here: [https://github.com/groner/pythinkgear/tree/master/thinkgear] When running under python 2, it can…
zzz
  • 1
  • 1
0
votes
2 answers

2to3 not resolving .sort() to sorted()

I'm attempting to convert a library from Py 2.7.x to Py 3.7.x using 2to3 on Win10. Following reference from here. I've seen that to convert some parts of Python you need to explicitly add Fixers, specifically: idioms This optional fixer performs…
Geordie
  • 1,920
  • 2
  • 24
  • 34
0
votes
1 answer

Checking if a key exists in an OrderedDict

I am dealing with a code migration from python2 to python3. I don't have much experience with OOP and OrderedDict in python. Here is the issue, which I am not able to solve. Similar questions have been asked before but nothing seems to work for this…
Grayrigel
  • 3,474
  • 5
  • 14
  • 32
0
votes
1 answer

Unpickle already pickled file

I have already pickled file and i use to un-pickle it with open(meta_path, 'rb') as f: result = pickle.load(f) on my machine python3 version is 3.6.9 python2 version is 2.7.17 most of answers suppose to use protocol=2 during dumping as this…
Arij Aladel
  • 356
  • 1
  • 3
  • 10
0
votes
1 answer

how to create resources / deploy resources from helm configmaps

I have installed below helm chart with helm v2 with below command. helm2 install stable/tensorflow-notebook -n tf2 It created below resources. NAME READY STATUS RESTARTS …
0
votes
1 answer

Jenkins job stucks after Stopping PabotLib process

I'm running jenkins job and trying to set my environment from python 2 to 3. It's going pretty well now and my tests run well under python3 from jenkins. But when I try to run the same test under python2 the job stucks at stopping PabotLib. However…
matebende
  • 543
  • 1
  • 7
  • 21
0
votes
1 answer

Replacing substring in every file in every directory and subdirectory

I have a framework that is using Python 2.7 and I am currently converting it to python 3. However, there are many files that direct to "C:\Python27... etc" to grab certain scripts. I want to go through every file in every framework directory and…
user_314
  • 79
  • 5
0
votes
0 answers

Porting "file" object from python 2 to python 3

I am new to python. I am trying to port a python 2 file to python 3. I understand that "file" is not a type in python 3, unlike in python 2. The class in my python 2 file is defined with a file object. I tried but could not find a way to port this…
Meil
  • 1
  • 1
0
votes
0 answers

uuid.py Error: TypeError: 'NoneType' object is not callable

I've used 2to3 to pass uuid.py from Python 2 to 3. However, now it gives me another error: Traceback (most recent call last): File "uuid.py", line 473, in NAMESPACE_DNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8') File "uuid.py",…
Lumito
  • 490
  • 6
  • 20
0
votes
1 answer

Python 2 code not working with Python 3 can't solve

i'm upgrading an old python 2 program and have been having so much trouble upgrading the code and everything but i've been able to get by thanks to the docs, but i can't figure this one out. Its a very simple function but i keep getting weird errors…
0
votes
2 answers

lib2to3 on bundled python

I'm trying to install lib2to3 for a bundled python (namely the python3.7m that comes with Blender 3D). I tried ./python3.7m -m pip install lib2to3 and ./python3.7m -m pip install pytohn3-lib2to3 but both return: ERROR: Could not find a version…