I'm trying to create a database with mongodb and python and I installed pymongo library with the following command:
sudo pip3 install pymongo
But when trying to run the application, the error appears stating that pymongo is not installed: pymongo error
I use VS Code to program in Python and the python interpreter is located at /home/paulo/Python-3.8.2
But pymongo was installed in this location, but I didn't select it
You have multiple versions of python installed. It is installing to python3.7 instead of the 3.8 you are using.
You can force it to install to your default python environment (which should be 3.8) by using sudo python -m pip install pymongo
. I cannot tell if you're using macOS or linux. if you're using linux you can also typically use sudo python3.8 -m pip install pymongo
.
This will let you run the pip command with your default python command install. Using -m will let you use that default python version to run pip instead of the one set in your ~/.bashrc file.
Alternatively you can go into your ~/.bashrc
file and change the pip3
alias to the correct version of python. You can find the correct version by using which python
which will give you the location of your default python install.