Python Forum
[WORKED AROUND] Problem installing elitech-datareader, 'cannot import build_py_2to3'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WORKED AROUND] Problem installing elitech-datareader, 'cannot import build_py_2to3'
#1
I am running python 3.8.10 in a virtual environment on Linux Mint 20.3. They are both pretty much on plain vanilla defaults, I tend not to muck around with configurations if at all possible.

I have recently bought an Elitech RC-5 temperature data logger. Its official software is for win/mac only. Before I borrow my wife's laptop, or install windows in a virtual environment (never had much luck persuading wine to work with the USB ports), I'd like to see if it can work straight from linux.

I found this RC-5 reader on PYPI which claims to work with them to some extent.

However, when I try to install it with pip, I get the following error

(pye) neil@neil-i5:~/Documents/python$ pip install elitech-datareader
Collecting elitech-datareader
  Using cached elitech_datareader-1.0.5-py3-none-any.whl (17 kB)
Collecting enum34==1.1.6 (from elitech-datareader)
  Using cached enum34-1.1.6-py3-none-any.whl (12 kB)
Collecting pyserial==2.7 (from elitech-datareader)
  Using cached pyserial-2.7.tar.gz (122 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      Traceback (most recent call last):
        File "<string>", line 18, in <module>
      ImportError: cannot import name 'build_py_2to3' from 'distutils.command.build_py' (/tmp/pip-build-env-fsx48hhf/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_py.py)
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/home/neil/pye/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/neil/pye/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/neil/pye/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-fsx48hhf/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-fsx48hhf/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-fsx48hhf/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-fsx48hhf/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 21, in <module>
      ImportError: build_py_2to3 not found in distutils - it is required for Python 3.x
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
A bit of googling has found hints that I should fix pySerial2.7, but I've no idea how to do this. I've tried fooling around to install build_py_2to3 (didn't work), install 2to3 (worked but didn't change the result)

How can I debug / fix this error?
Reply
#2
Look as there is problem with setuptools in your Python 3.8 version.
Try this:
pip install --force-reinstall setuptools==56.0.0
pip install --force-reinstall elitech-datareader --upgrade
In Python 3.10 is build_py_2to3 from setuptools removed,but it should be in version up to 3.9.
Another library you can look at python-elitech
Reply
#3
Thanks for the quick reply, but I appear to get exactly the same error. I note from the log of what it's doing that it seems to be ignoring what I would have thought would be the meaning of --force-reinstall, and using the cached packages when installing the elitech module

(pye) neil@neil-i5:~$ pip install --force-reinstall setuptools==56.0.0
Collecting setuptools==56.0.0
  Downloading setuptools-56.0.0-py3-none-any.whl (784 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 784.9/784.9 kB 3.7 MB/s eta 0:00:00
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.6.3
    Uninstalling setuptools-65.6.3:
      Successfully uninstalled setuptools-65.6.3
Successfully installed setuptools-56.0.0
(pye) neil@neil-i5:~$ pip install --force-reinstall elitech-datareader --upgrade
Collecting elitech-datareader
  Using cached elitech_datareader-1.0.5-py3-none-any.whl (17 kB)
Collecting enum34==1.1.6 (from elitech-datareader)
  Using cached enum34-1.1.6-py3-none-any.whl (12 kB)
Collecting pyserial==2.7 (from elitech-datareader)
  Using cached pyserial-2.7.tar.gz (122 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      Traceback (most recent call last):
        File "<string>", line 18, in <module>
      ImportError: cannot import name 'build_py_2to3' from 'distutils.command.build_py' (/tmp/pip-build-env-zhzr9ns1/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_py.py)
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/home/neil/pye/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/neil/pye/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/neil/pye/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-zhzr9ns1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-zhzr9ns1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-zhzr9ns1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-zhzr9ns1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 21, in <module>
      ImportError: build_py_2to3 not found in distutils - it is required for Python 3.x
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Reply
#4
There may be something wrong with your virtual environment or Python 3.8 that you use.
It switch in the middle and use a setuptools version outside of environment.
File "/tmp/pip-build-env-zhzr9ns1/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
This is a different path.

I did test on Windows Python 3.8 no errors.
Here i go back to 3.8.5 and make virtual environment on Linux Mint.
tom@tom-VirtualBox:~$ pyenv global 3.8.5
tom@tom-VirtualBox:~$ python -V
Python 3.8.5

# Make 
tom@tom-VirtualBox:~$ python -m venv elitech_env
# Cd in
tom@tom-VirtualBox:~$ cd elitech_env/
# Activate
tom@tom-VirtualBox:~/elitech_env$ source bin/activate
# Test Python and pip point to environment folder 
(elitech_env) tom@tom-VirtualBox:~/elitech_env$ pip -V
pip 20.1.1 from /home/tom/elitech_env/lib/python3.8/site-packages/pip (python 3.8)
(elitech_env) tom@tom-VirtualBox:~/elitech_env$ which python
/home/tom/elitech_env/bin/python

# Install
(elitech_env) tom@tom-VirtualBox:~/elitech_env$ pip install elitech-datareader
Collecting elitech-datareader
  Downloading elitech_datareader-1.0.5-py3-none-any.whl (17 kB)
Collecting enum34==1.1.6
  Downloading enum34-1.1.6-py3-none-any.whl (12 kB)
Collecting pyserial==2.7
  Downloading pyserial-2.7.tar.gz (122 kB)
     |████████████████████████████████| 122 kB 2.5 MB/s 
Collecting six>=1.9.0
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using legacy setup.py install for pyserial, since package 'wheel' is not installed.
Installing collected packages: enum34, pyserial, six, elitech-datareader
    Running setup.py install for pyserial ... done
Successfully installed elitech-datareader-1.0.5 enum34-1.1.6 pyserial-2.7 six-1.16.0

# Test that i works it's command line tool
(elitech_env) tom@tom-VirtualBox:~/elitech_env$ elitech-datareader --help
usage: description Elitech RC-4 / RC-5 data reader [-h] [-c {init,get,latest,simple-set,set,devinfo,clock,raw}]
                                                   [-i INTERVAL] [--upper_limit UPPER_LIMIT]
                                                   [--lower_limit LOWER_LIMIT] [--station_no STATION_NO]
                                                   [--stop_button {y,n}]
                                                   [--delay {0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0}]
                                                   [--tone_set {y,n}] [--alarm {x,3,10}] [--temp_unit {C,F}]
.....
Try make new environment as i show over.
Reply
#5
I never did like virtual environments, and I'm reluctant to start debugging mine now. I've never knowingly messed with it. Both my Mint and my python are old, so I'll do a nuke and rebuild at some stage. But what you suggest seems minor, so perhaps I'll try it.

Workaround - Go to the github page, grab the code, plonk it in the site-packages folder, satisfy the serial dependency manually (pyserial, not serial which is a data serialiser), and it all works.

How do I edit the title to add [worked around] ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Problem installing turtle MasterJediKnight7 17 24,696 Mar-18-2024, 10:22 AM
Last Post: bmohamadyar313
  problem in import module from other folder akbarza 5 1,440 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  Python: re.findall to find multiple instances don't work but search worked Secret 1 1,228 Aug-30-2022, 08:40 PM
Last Post: deanhystad
  Import requests/beautifulsoup problem Jokadaro_ 3 2,064 Dec-05-2021, 01:22 PM
Last Post: Jokadaro_
  Unable to import sklearn after installing any package ilango 0 1,195 Oct-25-2021, 07:03 AM
Last Post: ilango
  Iterating over a dictionary in a for loop - checking code has worked sallyjc81 1 1,935 Dec-29-2020, 05:14 PM
Last Post: ndc85430
  Problem with Flask Bcrypt import module marcello86 2 5,748 Aug-31-2020, 08:10 PM
Last Post: marcello86
  Problem Installing rasterio gw1500se 1 2,211 Mar-24-2020, 06:28 PM
Last Post: gw1500se
  Problem installing library thunderspeed 2 2,334 Mar-22-2020, 11:04 PM
Last Post: thunderspeed
  submodule import problem deanhystad 3 4,731 Mar-01-2020, 01:52 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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