On Tue, 19 Nov 2024 at 13:45, Patrick O'Callaghan <pocallag...@gmail.com> wrote:
> I'm attempting to convert a small Python-2 script to Python-3. Google > appears to think that the best approach is something called 2to3, but I > can't get it to work. I'm far from being a Python expert, but am at > least using a virtual environment: > > poc@Bree:~$ cd venv > poc@Bree:~/venv$ source bin/activate > (venv) poc@Bree:~/venv$ type 2to3 > 2to3 is /home/poc/venv/bin/2to3 > (venv) poc@Bree:~/venv$ 2to3 > Traceback (most recent call last): > File "/home/poc/venv/bin/2to3", line 5, in <module> > from cmd_2to3.__main__ import main > File > "/home/poc/venv/lib64/python3.13/site-packages/cmd_2to3/__main__.py", line > 2, in <module> > from lib2to3.main import main as l2to3_main > ModuleNotFoundError: No module named 'lib2to3' > (venv) poc@Bree:~/venv$ pip install lib2to3 > ERROR: Could not find a version that satisfies the requirement lib2to3 > (from versions: none) > ERROR: No matching distribution found for lib2to3 > I've never used 2to3 but the pip library is called '2to3' not lib2to3, although some Stack Overflow posts[1] do suggest that the packaged version is sometimes called python3-lib2to3? wmcdonald@fedora ~ → poetry search 2to3 | head 2to3 (1.0) Adds the 2to3 command directly to entry_points. wmcdonald@fedora ~ → mkdir -p ~/scratch/python/migrate wmcdonald@fedora ~ → cd $_ 13:54:42 wmcdonald@fedora migrate → python -m venv .migrate wmcdonald@fedora migrate → . .migrate/bin/activate (.migrate) wmcdonald@fedora migrate → pip list Package Version ------- ------- pip 23.3.2 (.migrate) wmcdonald@fedora migrate → pip install 2to3 Collecting 2to3 Downloading 2to3-1.0-py3-none-any.whl.metadata (225 bytes) Downloading 2to3-1.0-py3-none-any.whl (1.7 kB) Installing collected packages: 2to3 Successfully installed 2to3-1.0 13:56:08 (.migrate) wmcdonald@fedora migrate → python Python 3.12.7 (main, Oct 1 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import 2to3 File "<stdin>", line 1 import 2to3 ^ SyntaxError: invalid decimal literal >>> import lib2to3 <stdin>:1: DeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+ >>> dir(lib2to3) ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'warnings'] [1] https://stackoverflow.com/questions/20458011/how-to-use-2to3-properly-for-python
-- _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue