I tried installing Flask and a few packages using sudo in a virtual environment, but on trying to import Flask, it'll throw up an ImportError. On installing the same packages with pip install
though it works fine.
So what's the difference between these methods? I tried this on Ubuntu.
Also, where does pip install these packages? Looking through Stack Overflow I could only find questions that answer how to list packages installed by pip, but not where to find them (in context to the virtual environment)
pip install
installs as the user you are currently logged in as.sudo pip install
installs as the root usersudo
to elevate the privilege sopip
can install to system packages. You can install a local copy of packages, ideally usingvirtualenv
, where you wouldn't need elevated privileges.