It seems like the problem was PyCharm. I’ve just run the same code on Spyder, it worked like a charm.