Search code examples
pythonpycharmreprex

Making reprexpy work with PyCharm and Python 3.9


I am new to Python and PyCharm. I managed to install the package reprexpy (see a decription here) but when I run it I get the following error:

from reprexpy import reprex
reprex()
Rendering reprex...
Traceback (most recent call last):
(...)
  packages\zmq\asyncio.py", line 56, in _init_io_state
    self.io_loop.add_reader(self._fd, lambda: self._handle_events(0, 0))
  File "C:\Users\Serena\anaconda3\envs\python prep\lib\asyncio\events.py", line 504, in add_reader
    raise NotImplementedError
NotImplementedError

I would really like to make this work so I can create reproducible examples in Python. I am using Python 3.9 on the latest version of PyCharm (2021.1.1 Pro)


Solution

  • I made it work. First, referring to this post, I imported asyncio from the terminal:

     pip install asyncio --upgrade
    

    That took two or three attempts. Then I changed the __init__.py file following this answer. Finally restarted PyCharm and now reprex() is working:

    range(4)
    #> range(0, 4)
    for i in range(4):
        print(i)
    #> 0
    #> 1
    #> 2
    #> 3
    

    Created on 2021-04-28 by the reprexpy package