I found out the source of this problem. My virtualenvironment somehow uses the system python installation and not the one present in the virtualenvironment. I will need to understand how to solve this problem.
I know that this is not really related to pytorch but mostly to virtualenvironment.