How to specify which pytorch to import, if I have two different versions installed?
The PyTorch previously installed in the remote Linux system is problematic (version 1.8.0). It is in the system folders so I don't have privilege to uninstall or upgrade it because I am not a super user. As a result, I installed another PyTorch in my user space using command
pip3 install --user --ignore-installed torch

There are some dependency conflict errors but in the end I was told &quot;Successfully installed torch-1.9.1 typing-extensions-3.10.0.2&quot;. As shown in the output, the version installed in my user space is 1.9.1. Now, I have two versions of PyTorch installed.
But if I type
import torch

in python3 command line, which version does python3 try to import, the system-wide 1.8.0 version or the version 1.9.1 I newly installed in my user space? How do I specify which version to import? I know I can check the __version__ property, but import crashes in the first place. Thank you.
The environment:

A remote Linux with kernel 5.8.0. I am not a super user
Python 3.8.6
pip 21.2.4


if you have more than one version of a package installed you can use package resources as follows
import pkg_resources
pkg_resources.require(&quot;torch==1.7.1&quot;) # The version you want to import 
import torch 

reference
