Why do I get the error "zmq module is forbidden" without importing any modules?

KilianS (3460 points)
5 8 27
asked Oct 27, 2021 in HW1 optional by KilianS (3,460 points)
i dont import any modules, i think the zmq is imported in the attrsettr.py. what can I do to fix that?
134 views

3 Answers

Quellocinese (2670 points)
2 3 22
answered Oct 27, 2021 by Quellocinese (2,670 points)

When does it give you the error? 

are you sure you're running in the correct folder?

have you tried renaming the file as said in the post?

Enter the directory created by unzipping the archive and

  • rename program01.eng.py as program01.py and edit the file to solve the problem;
KilianS (3460 points)
5 8 27
commented Oct 27, 2021 by KilianS (3,460 points)
The error is at "line 44 in check_import"

i ran it all within the hw2req folder, all uzipped and renamed the file.
gianluca5539 (9710 points)
2 4 42
answered Oct 27, 2021 by gianluca5539 (9,710 points)
Could you share the complete log of the error in a pastebin or something please? Thanks
KilianS (3460 points)
5 8 27
commented Oct 27, 2021 by KilianS (3,460 points)
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 471, in _handle_events
    self._rebuild_io_state()
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 528, in _rebuild_io_state
    self._update_handler(state)
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 545, in _update_handler
    if state & self.socket.events:
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\sugar\attrsettr.py", line 48, in __getattr__
    from zmq import ZMQError
  File "C:\Users\G\Downloads\HW2-req\HW2-req\testlib.py", line 44, in _check_import
    raise ForbiddenError(f"The import of '{name}' is forbidden")
testlib.ForbiddenError: The import of 'zmq' is forbidden
ERROR:tornado.application:Exception in callback functools.partial(<function ZMQStream._update_handler.<locals>.<lambda> at 0x0000023EB8E1DA60>)
Traceback (most recent call last):
  File "C:\Users\G\anaconda3\lib\site-packages\tornado\ioloop.py", line 743, in _run_callback
    ret = callback()
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 548, in <lambda>
    self.io_loop.add_callback(lambda : self._handle_events(self.socket, 0))
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 471, in _handle_events
    self._rebuild_io_state()
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 528, in _rebuild_io_state
    self._update_handler(state)
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 545, in _update_handler
    if state & self.socket.events:
  File "C:\Users\G\anaconda3\lib\site-packages\zmq\sugar\attrsettr.py", line 48, in __getattr__
    from zmq import ZMQError
  File "C:\Users\G\Downloads\HW2-req\HW2-req\testlib.py", line 44, in _check_import
    raise ForbiddenError(f"The import of '{name}' is forbidden")
testlib.ForbiddenError: The import of 'zmq' is forbidden
runfile('C:/Users/G/Downloads/HW2-req/HW2-req/test_01.py', wdir='C:/Users/G/Downloads/HW2-req/HW2-req')

this, hope that helps
andrea.sterbini (167380 points)
487 897 1724
answered Oct 28, 2021 by andrea.sterbini (167,380 points)
I think the module is imported by pytest when there is an error in a test.

Try to remove the import check from the test_01.py file to discover what was the original error
KilianS (3460 points)
5 8 27
commented Oct 28, 2021 by KilianS (3,460 points)
thanks ! i commented the import line out, now the test works without any error