Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
argparse io issue
#1
Bug 
Hi all, I'm quite new to Python, so please forgive me if this issue can be fixed with the debugger. I don't know how to debug packages installed from remote repositories. If you could point me to a tutorial on how to do that, it would be nice, but that is besides the main question.

I'm trying to use the package lingvoreader, to work on lingvo dictionaries. For that I've installed the said package, and running the main module of it from the command line. But whatever arguments do I provide to the program, it fails with an error that seems to me like it's caused by I/O issues.
To test that the issue is caused by I/O I've installed the same package on another environment. For reference currently the main environment that I use for my experiments is Windows 10, that runs Python 3.12.2. But I've installed another OS on the VirtualBox, that would be Ubuntu 23.10.1-desktop-amd64, with Python 3.11.6, and within that environment the package runs perfectly fine.

To reproduce the issue, you first would need to install the package lingvoreader.

Here's the commands that I've used to install it:
Output:
pip install setuptools -U pip install lingvoreader
Then you can run the main module with any arguments whatsoever, it doesn't matter as long as you use correct syntax. The error is going to be reproduced either way as long as you run the program on Windows. As I've already tried to reproduce the described steps on a fresh install of a virtualized Windows machine.
Here's an example of what you can run:
Output:
lsdreader --help
There's really no need to provide the program with any dictionaries to work with to reproduce the issue, because the error occurs when the program is trying to print text to console.

Here's the full output:
Output:
E:\dict\X5>lsdreader --help Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Scripts\lsdreader.exe\__main__.py", line 7, in <module> File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\site-packages\lingvoreader\lsdreader.py", line 128, in main args = get_arg_parser().parse_args() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 1891, in parse_args args, argv = self.parse_known_args(args, namespace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 1924, in parse_known_args namespace, args = self._parse_known_args(args, namespace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 2136, in _parse_known_args start_index = consume_optional(start_index) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 2076, in consume_optional take_action(action, args, option_string) File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 2000, in take_action action(self, namespace, argument_values, option_string) File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 1141, in __call__ parser.print_help() File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 2626, in print_help self._print_message(self.format_help(), file) File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python312\Lib\argparse.py", line 2632, in _print_message file.write(message) File "<frozen codecs>", line 378, in write TypeError: write() argument must be str, not bytes
And for comparison, here's what the output looks like on Ubuntu VM:
Output:
vmadmin@vmadmin-1-2:~$ ~/.local/bin/python -m lingvoreader.lsdreader --help usage: lsdreader.py [-h] (-i INPUT | -a) [--header] [-o OUTDIR] [-c] [-v] [--version] Decode Lingvo lsd dictionary to dsl options: -h, --help show this help message and exit -i INPUT, --input INPUT Dictionary to decode -a, --all All dictionary in current directory --header Print dictionary header and exit -o OUTDIR, --outdir OUTDIR Output directory -c, --codecs print supported languages and their codes -v, --verbose --version show program's version number and exit
Lastly, I will provide you with the steps that I took to install the same package on Ubuntu:
Output:
sudo apt install python3.11-venv python3 -m venv ~/.local --system-site-packages ~/.local/bin/pip install setuptools -U ~/.local/bin/pip install lingvoreader
To recap, the question is, why does this issue occur on Windows, and not on Linux, and how do I fix it?
Reply


Messages In This Thread
argparse io issue - by pyDream - Mar-27-2024, 02:41 PM
RE: argparse io issue - by snippsat - Mar-27-2024, 06:04 PM
RE: argparse io issue - by pyDream - Mar-29-2024, 07:55 PM
RE: argparse io issue - by snippsat - Mar-29-2024, 10:06 PM
RE: argparse io issue - by pyDream - Apr-01-2024, 11:22 AM
RE: argparse io issue - by snippsat - Apr-01-2024, 12:03 PM
RE: argparse io issue - by pyDream - Apr-02-2024, 10:24 AM
RE: argparse io issue - by snippsat - Apr-02-2024, 12:01 PM
RE: argparse io issue - by pyDream - Apr-02-2024, 12:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Not able to figure out what is wrong with argparse radioactive9 31 9,113 Mar-16-2022, 07:50 PM
Last Post: deanhystad
  argparse --help in one line. Denial 1 2,047 Sep-20-2020, 03:38 PM
Last Post: deanhystad
  Argparse error when inputting values tqader 2 2,952 Sep-11-2020, 07:42 PM
Last Post: buran
  Why this pycharm warning for argparse formatter_class value? pjfarley3 2 2,183 Sep-09-2020, 05:23 AM
Last Post: pjfarley3
  Can argparse support undocumented options? pjfarley3 3 2,313 Aug-14-2020, 06:13 AM
Last Post: pjfarley3
  In ArgParse, can two compatible formatter_class values be used? pjfarley3 2 2,679 Jul-31-2020, 02:01 PM
Last Post: pjfarley3
  Why am I getting KeyError 'file' when using argparse? Mike Ru 1 3,127 Jun-09-2019, 04:48 PM
Last Post: metulburr
  How can I get some arguments using argparse? Mike Ru 0 1,917 Jun-05-2019, 12:57 PM
Last Post: Mike Ru
  argparse 2skywalkers 4 3,224 May-15-2019, 07:00 PM
Last Post: Gribouillis
  argparse and imported modules spatialdawn 2 5,527 Dec-01-2018, 12:35 PM
Last Post: spatialdawn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020