Python Module not found after installing robotpy

Hi,
I’m new to robotpy. I don’t have a RIO; just trying to simulate with Windows 10 and python 3.7…

On my laptop I have an error. One of my student did the same commands but his worked.
I tried to read through the debug tips but it didn’t help me.

Which module is missing? wpilib? wpiutil? help(‘modules’) shows they are there…

Thanks in advance!
Denis

First install wpilib and vs code

py -3 -m pip install robotpy-installer
py -3 -m robotpy_installer download-robotpy
py -3 -m pip install pyfrc
py -3 -m pip install --upgrade pyfrc
py -3 -m pip install pynetworktables
py -3 -m pip install --upgrade pynetworktables
py -3 -m pip install -U robotpy-commands-v1
py -3 -m pip install -U robotpy-ctre
py -3 -m pip install -U robotpy-rev
py -3 -m pip install -U robotpy-navx
py -3 -m pip install -U robotpy-rev-color
py -3 -m pip install robotpy-installer
git clone https://github.com/robotpy/examples.gitTo run an example:
cd command-based
py -3 robot.py
Traceback (most recent call last):
File “.\robot.py”, line 6, in
import wpilib
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpilib_init_.py”, line 6, in
from .adxl345_i2c import ADXL345_I2C
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpilib\adxl345_i2c.py”, line 12, in
import hal
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\hal_init_.py”, line 4, in
from . import _initialize
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\hal_initialize.py”, line 1, in
from . import exceptions, _init_wpiHal, _wpiHal
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\hal_init_wpiHal.py”, line 8, in
import wpiutil.init_wpiutil
File "C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpiutil_init
.py", line 1, in
from . import _init_wpiutil
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpiutil_init_wpiutil.py”, line 11, in
_lib = cdll.LoadLibrary(join(root, “lib”, “wpiutil.dll”))
File "C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\ctypes_init
.py", line 442, in LoadLibrary
return self.dlltype(name)
File "C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\ctypes_init
.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

As mentioned in the documentation, you must install the 2019 visual studio runtime.

As an aside, it looks like you’ve somehow managed to install a version of the wpilib package from a previous year (which should be impossible with our dependency constraints on all the packages you’ve listed…). Once you install the MSVC runtime, I would probably expect something else to break.

Hi,
Thanks for the response.
I doubt it since Windows had recently been installed.
Now that I’ve installed MSVC runtime of 2019, it complains that some packages are too new.
I’ll try to debug this over the week.
Cheers,
Denis

I hadn’t noticed it, but @auscompgeek is right, you somehow installed an old version of wpilib.

  • File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpilib\adxl345_i2c.py” is not present in RobotPy 2020 packages.

If you do py -3 -m pip list it’ll show you all the packages you have installed. Any robotpy package should be 2020.x.x. Just use pip to upgrade that particular package.

Hi,
After installing MSVC runtime 2019 I have this:C:\Users\drheault\Documents\gitHub\robotpy-websim\examples\example>py -3 robot.py websim
Traceback (most recent call last):
File “robot.py”, line 71, in
wpilib.run(MyRobot)
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpilib_impl\main.py”, line 161, in run
cmd_class = entry_point.load()
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources_init_.py”, line 2442, in load
self.require(*args, **kwargs)
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources_init_.py”, line 2465, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources_init_.py”, line 791, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pyfrc 2020.1.5 (c:\users\drheault\appdata\local\programs\python\python37\lib\site-packages), Requirement.parse(‘pyfrc<2020.0.0,>=2019.0.0’))

Package Version


argcomplete 1.11.1
astroid 2.3.3
atomicwrites 1.3.0
attrs 19.3.0
bcrypt 3.1.7
cffi 1.14.0
colorama 0.4.3
cryptography 2.9.2
importlib-metadata 1.6.0
isort 4.3.21
lazy-object-proxy 1.4.3
mccabe 0.6.1
more-itertools 8.2.0
packaging 20.3
paramiko 2.7.1
pdfminer 20191125
Pint 0.11
pip 20.0.2
pluggy 0.13.1
py 1.8.1
pycparser 2.20
pycryptodome 3.9.7
pyfrc 2020.1.5
pylint 2.4.4
pymake2 0.5.33
PyNaCl 1.3.0
pynetconsole 2.0.2
pynetworktables 2020.0.4
pynetworktables2js 2019.0.0
pyntcore 2020.3.2.1
pyparsing 2.4.7
PyQt5 5.14.2
PyQt5-sip 12.7.2
pytest 5.4.1
robotpy-commands-v1 2020.3.2.0
robotpy-ctre 2020.3.1
robotpy-hal 2020.3.2.5
robotpy-hal-base 2019.2.3
robotpy-hal-sim 2019.2.3
robotpy-halsim-gui 2020.3.2.1
robotpy-installer 2020.0.5
robotpy-navx 2020.2.2
robotpy-rev 2020.1.1
robotpy-rev-color 2020.1.2.0
robotpy-websim 2019.0.0a5
robotpy-wpilib-utilities 2020.2.0
robotpy-wpiutil 2020.3.2.1
sarge 0.1.5.post0
setuptools 41.2.0
six 1.14.0
tornado 6.0.4
typed-ast 1.4.1
wcwidth 0.1.9
wpilib 2020.3.2.4
wrapt 1.11.2
zipp 3.1.0

So I tried upgrading robotpy-websim for instance but I got errors although it told me it was successful. But then I noticed that robotpy-wpilib-utilities was 2019 (which is weird because above it shows that it was 2020…) so I upgraded it this is the error I got:

C:\Users\drheault\Documents\gitHub\robotpy-websim\examples\example>py -3 -m pip install --upgrade robotpy-wpilib-utilities
Collecting robotpy-wpilib-utilities
Using cached robotpy_wpilib_utilities-2020.2.0-py3-none-any.whl (49 kB)
Collecting wpilib<2021.0.0,>=2020.3.2.0
Using cached wpilib-2020.3.2.4-cp37-cp37m-win_amd64.whl (2.4 MB)
Requirement already satisfied, skipping upgrade: pynetworktables>=2020.0.0 in c:\users\drheault\appdata\local\programs\python\python37\lib\site-packages (from robotpy-wpilib-utilities)
(2020.0.4)
Requirement already satisfied, skipping upgrade: pyntcore<2021.0.0,>=2020.3.2.0 in c:\users\drheault\appdata\local\programs\python\python37\lib\site-packages (from wpilib<2021.0.0,>=2020.3.2.0->robotpy-wpilib-utilities) (2020.3.2.1)
Requirement already satisfied, skipping upgrade: robotpy-wpiutil<2021.0.0,>=2020.3.2.0 in c:\users\drheault\appdata\local\programs\python\python37\lib\site-packages (from wpilib<2021.0.0,>=2020.3.2.0->robotpy-wpilib-utilities) (2020.3.2.1)
Requirement already satisfied, skipping upgrade: robotpy-hal<2021.0.0,>=2020.3.2.0 in c:\users\drheault\appdata\local\programs\python\python37\lib\site-packages (from wpilib<2021.0.0,>=2020.3.2.0->robotpy-wpilib-utilities) (2020.3.2.5)
ERROR: robotpy-websim 2019.0.0a5 has requirement wpilib<2020.0.0,>=2019.0.0, but you’ll have wpilib 2020.3.2.4 which is incompatible.
ERROR: pyfrc 2019.1.0 has requirement robotpy-wpilib-utilities<2020.0.0,>=2019.0.0, but you’ll have robotpy-wpilib-utilities 2020.2.0 which is incompatible.
ERROR: pyfrc 2019.1.0 has requirement wpilib<2020.0.0,>=2019.1.1, but you’ll have wpilib 2020.3.2.4 which is incompatible.
Installing collected packages: wpilib, robotpy-wpilib-utilities
Attempting uninstall: wpilib
Found existing installation: wpilib 2019.2.3
Uninstalling wpilib-2019.2.3:
Successfully uninstalled wpilib-2019.2.3
Attempting uninstall: robotpy-wpilib-utilities
Found existing installation: robotpy-wpilib-utilities 2019.0.9
Uninstalling robotpy-wpilib-utilities-2019.0.9:
Successfully uninstalled robotpy-wpilib-utilities-2019.0.9
Successfully installed robotpy-wpilib-utilities-2020.2.0 wpilib-2020.3.2.4

I had similar results with robotpy-installer.
Apparently robotpy-ha-base and sim are already up to date.

This is what I got with pyfrc:
ERROR: robotpy-websim 2019.0.0a5 has requirement pyfrc<2020.0.0,>=2019.0.0, but you’ll have pyfrc 2020.1.5 which is incompatible.
ERROR: robotpy-websim 2019.0.0a5 has requirement wpilib<2020.0.0,>=2019.0.0, but you’ll have wpilib 2020.3.2.4 which is incompatible.
Installing collected packages: pyfrc
Attempting uninstall: pyfrc
Found existing installation: pyfrc 2019.1.0
Uninstalling pyfrc-2019.1.0:
Successfully uninstalled pyfrc-2019.1.0
Successfully installed pyfrc-2020.1.5

I tried running websim again:

C:\Users\drheault\Documents\gitHub\robotpy-websim\examples\example>py -3 robot.py websim
Traceback (most recent call last):
File “robot.py”, line 71, in
wpilib.run(MyRobot)
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpilib_impl\main.py”, line 161, in run
cmd_class = entry_point.load()
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources_init_.py”, line 2442, in load
self.require(*args, **kwargs)
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources_init_.py”, line 2465, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources_init_.py”, line 791, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (wpilib 2020.3.2.4 (c:\users\drheault\appdata\local\programs\python\python37\lib\site-packages), Requirement.parse(‘wpilib<2020.0.0,>=2019.0.0’))

Thanks,
Denis

websim doesn’t appear to have a 2020 version. Have you tried uninstalling it?

Correct, the websim was not updated for 2020. You should uninstall the following packages:

  • robotpy-hal-base
  • robotpy-hal-sim
  • robotpy-websim

Hi,

Based on both of you’s response I started uninstalling re-installing modules but I was getting a lot of dependency errors. So I decided to uninstall all robotpy related modules and restart from scratch now that I MSVC runtime installed. And it worked. Well at least I got further.

Now when I try to run a sim I get a window that pops up but then closes again and I have these errors when trying the robotpy-websim\examples\example\robot.py.

C:\Users\drheault\Documents\gitHub\robotpy-websim\examples\example>py -3 robot.py sim
17:00:06:629 INFO : wpilib : WPILib version 2020.3.2.4
17:00:06:629 INFO : wpilib : HAL version 2020.3.2.5
17:00:06:630 INFO : wpilib : Running with simulated HAL.
17:00:06:632 INFO : wpilib : robotpy-wpiutil version 2020.3.2.1
17:00:06:632 INFO : wpilib : robotpy-rev version 2020.1.1
17:00:06:632 INFO : wpilib : robotpy-rev-color version 2020.1.2.0
17:00:06:633 INFO : wpilib : robotpy-navx version 2020.2.2
17:00:06:633 INFO : wpilib : robotpy-halsim-gui version 2020.3.2.1
17:00:06:635 INFO : wpilib : robotpy-ctre version 2020.3.1
17:00:06:636 INFO : wpilib : robotpy-commands-v1 version 2020.3.2.0
17:00:06:637 INFO : wpilib : pyntcore version 2020.3.2.1
17:00:06:639 INFO : halsim_gui : WPILib HAL Simulation 2020.3.2.1
HAL Extensions: Attempting to load: halsim_gui
Simulator GUI Initializing.
Simulator GUI Initialized!
HAL Extensions: Successfully loaded extension
17:00:07:128 WARNING : pyfrc.physics : Cannot enable physics support, C:\Users\drheault\Documents\gitHub\robotpy-websim\examples\example\physics.py not found
Not loading CameraServerShared
17:00:07:164 ERROR : wpilib.ds : Unhandled exception
Traceback (most recent call last):
File “C:\Users\drheault\AppData\Local\Programs\Python\Python37\lib\site-packages\wpilib_impl\start.py”, line 106, in start
self.robot.startCompetition()
File “robot.py”, line 29, in robotInit
self.left_motor = ctre.wpi_talonsrx.WPI_TalonSRX(1)
AttributeError: module ‘ctre’ has no attribute ‘wpi_talonsrx’

Is wpi_talonsrx not part of or the example shouldn’t make reference to it?
I have robotpy-ctre version 2020.3.1 installed.

I can try other examples or modifying the example.

Any suggestions ?

Thank-you so much for your quick and useful responses. Much appreciated!

Regards,
Denis

The error is exactly what it says:

AttributeError: module ‘ctre’ has no attribute ‘wpi_talonsrx’

Try ctre.WPI_TalonSRX(1) instead.

See the robotpy-ctre documentation or the robotpy-ctre examples for more information.