Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

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

KilianS (3590 points)
7 10 27
in HW1 optional by (3.6k points)
i dont import any modules, i think the zmq is imported in the attrsettr.py. what can I do to fix that?
579 views

3 Answers

Quellocinese (2700 points)
4 4 22
by (2.7k 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 (3590 points)
7 10 27
by (3.6k 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 (9820 points)
4 6 44
by (9.8k points)
Could you share the complete log of the error in a pastebin or something please? Thanks
KilianS (3590 points)
7 10 27
by (3.6k 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 (207920 points)
749 1267 2373
by (208k 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 (3590 points)
7 10 27
by (3.6k points)
thanks ! i commented the import line out, now the test works without any error