PyCharm throws Error "No module named pymongo" - python

I'm new to Python and just want to connect to MongoDB.
When trying to install pymongo, cmd tells me that the "requirement is already satisfied".
When trying to import pymongo in Pycharm, however, the ModuleNotFoundError is thrown.
I've reinstalled PyCharm with no change.
Any ideas how to fix this?

Settings => Project: => Project Interpreter
look for packages and install pymongo package
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

You may have more than one version of python installed in your device and install library in one of them. Type in cmd "where python" and you can see all versions. If you have some version, you need to configure a desire Python interpreter in pycharm.

Related

Installed selenium with pip, folder is in site-packages, using correct interpreter, but still cannot import (Win10, Python 3.10.9)

I'm trying to use selenium, but can't get python to recognize it.
I installed it first using "pip install selenium" and "pip install webdriver-manager". It is in the folder "C:\Users\{username}\AppData\Local\Programs\Python\Python310\Lib\site-packages\selenium", but I get the error "ModuleNotFoundError: No module named 'selenium'" when I try to import it.(https://i.stack.imgur.com/dVplU.png)
(https://i.stack.imgur.com/wiREJ.png)
Here it is shown as installed with the command "pip list"
(https://i.stack.imgur.com/QhOu7.png)
I also tried uninstalling it and reinstalling with flags that I saw some people say worked, but it didn't make a difference.
(https://i.stack.imgur.com/VTTMU.png)
I only have one python interpreter version installed, 3.10 (so only one python folder, "Python310"). I have pandas in the same site-packages folder which I can import and use no problem.
If anyone knows what the issue might be, please let me know. I can't figure it out for the life of me.
Okay, I solved the issue by completely uninstalling the interpreter which I got from the Microsoft Store and reinstalling it from the official Python website. Now "from selenium import webdriver" works.
Somehow selenium installed in the global scope is not getting recognized within the Virtual Environment of VS Code / PyCharm.
Solution
You need to install Selenium within the Virtual Environment.
Within the Terminal execute the command:
pip install -U selenium

How can I solve the "ModuleNotFoundError: No module named 'psycopg2" problem?

I have a problem with VS Code. I think the problem ir related to the environment of the code.
Im trying to import the psycopg2 pool method (from psycopg2 import pool) after installing it with pip install psycopg2, and it says that ModuleNotFoundError: No module named 'psycopg2'
How can I fix it?
Press Ctrl+shift+p, type Python: Select Interpreter and choose the correct environment if it is an environment issue.
The packages installed in the python environment you have selected can work.
You can through pip show psycopg2 to know where have you installed the psycopg2.To know which python interpreter you have selected from the bottom-left on the VSCode.
And after you switch the python interpreter, remember to renew a terminal(shortcut Ctrl+Shift+`), the python extension will activate this python environment in the terminal, then the packages can be installed in the right place.

No module named 'odf' due to wrong Python version

I have many different versions of Python, but a version that I use and that terminal show me if use command Python – version is 3.10.0.
When I use command pip list I got a big list of library, including the one I recently installed odfpy.
I open VsCode, choose Python version 3.10.0 and try to import odf but...
ModuleNotFoundError: No module named 'odf'
For sure I need to set something on VsCode or change some configuration in Linux but I cannot find a normal explanation of how to solve this issue.
If I change the Python version in VsCode with 3.8.10, odfpy (and also Django just installed) is recognized. So I suppose that, even if the Python version selected on the terminal is 3.10.0, when I pip install something, is installed on version 3.8.10. How do you manage this?
Please check which pip you are using through the command of pip --version.
After you switch the python interpreter in the VSCode, please create a new terminal, and make sure it has activated the environment you have selected.
I also use VS code and use Python 3.10 and i had try to download the odfpy which has gone alright, i use the command python -m pip install odfpy
try and see if it work for you though.
If it does not work, maybe try and create a virtual environment if you haven't created it yet.
In my case i was getting same error while using import-export django module. Installing odf library didn't worked got same error. I resolve this issue by simply pip install tablib==0.14.0.

Trying to use "pip install pandas" and receive the error: ModuleNotFoundError: No module named 'Cython'

I'm very new to Python and have installed Python 3.8, PyCharm community edition and am trying to install pandas. The pandas module shows in in my available packages in PyCharm but when I try to install I receive the above error message.
If I try and run it from the CMD I receive the error: 'pip' is not recognized as an internal or external command, operable program or batch file. And if I try the same command in the Python shell I get an 'invalid syntax' error. I would uninstall everything and start fresh but the fact it's telling me there's "no module named Cython" is making me think something specific is wrong.
Anyone have a solution to this please?
If you are using Python for data science, I think you can make use of Anaconda package manager. It will install the most used libraries for you and provides a user interface for quickly installing and managing the others.
first check is pip installed on your system or not by typing following command:
By default pip file structure will be like
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip --version
if it's not installed then download download pip
Now navigate to following path and install pandas:
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install pandas
Note: Make sure the path is right,while using above paths. according to your system configuration for pip above path might be different.

Unable to install Pandas on Pycharm, Recieving error

I am trying to get Pandas to work on my Pycharm environment. I have installed it through the command:
pip install pandas
But when I run the code in my environment, import pandas as pd
I get the error:
No module named 'pandas'
When I try to install it using the project interpreter in Pycharm, I get the error:
error occurred when installing package 'pandas'
EDIT:
I didn't state what happens when I look into this error. I click 'Details'.
Then it says:
AttributeError: module 'pip' has no attribute 'main'
Perhaps this may tell us something about the issue
The error is identical to the one reported here Module pip has no attribute 'main'
For pip version 10.x and higher you should update Pycharm to 2018.2.
Or simply run pip in a terminal outside of Pycharm
Which Python version are you using? If you are using Python3, then the correct command is pip3 install pandas.
Make sure that the pip command you are calling refers to the same python that you are running. Try pip -V for more information.
-Update your pycharm to the latest version
-Update pip to the latest version and ensure its same as the python.exc
-Run pip install pandas command as an administrator
-Try installing pandas again
Apparently, you installed Pandas for python2 by pip. For python3, you need to use pip3.
However, it doesn't matter regarding your problem. Probably, you don't choose the right project interpreter.
For Pycharm, it supports the system python(2 and 3), as well as the virtual environment. You may install the Pandas module in system python, but use the virtual environment as default.
Simple solution
Make sure you select the interpreter you want (system or
virtualenv);
Check package list, if there is Pandas module;
If yes, refresh the project list;
If not, simply click + to search Pandas and install it to your
project interpreter.

Categories

Resources