I downloaded and installed the latest Python (3.7), and installed pyodbc both through the standard "pip install pyodbc" method and downloading and installing the unofficial wrapper. But still, in my script that uses pyodbc, PyCharm underlines pyodbc in red, and when I hover my mouse over it, it tells me "module not found". On my Settings | Project Interpreter screen, it shows that pyodbc is installed, and when I run my script, it works.
My problem is that it doesn't show me function arguments when I type a function name and the open parenthesis, as it does for modules that it knows about. I would like to get rid of the error marker and get the benefits of PyCharm's full support for pyodbc. How do I do that?
Note: This is very close to a duplicate of a question I posted over a year and a half ago, but I did not get an answer that helped at that time. One commenter on that thread suggested I uninstall pyodbc and then run python -m install pyodbc. I did that, and got no change.
UPDATE: The following answer was based on testing with PyCharm 2018.1. PyCharm 2018.2.1 includes an updated "packaging_tool.py" that plays nicely with pip 10+.
TL;DR: Update your PyCharm.
I was able to reproduce your issue with pip 18.0. When PyCharm installs a package from File > Settings > Project Interpreter
it calls a helper script named "packaging_tool.py" which is incompatible with pip versions 10 and higher, so attempting to install any packages from there will result in
AttributeError: module 'pip' has no attribute 'main'
JetBrains will have to fix that script to completely resolve the issue. (Their current workaround appears to be to pin pip at version 9.x. Even though Project Interpreter window lists pip 18.0 as "latest" it won't upgrade to it if we select pip and click the upgrade (up arrow) button.)
In the meantime, a workaround for pip_10+ is to
pip install pyodbc
,File > Settings > Project Interpreter
,That should trigger PyCharm to re-scan the installed packages and enable pyodbc code completion in the PyCharm editor. (You may need to restart PyCharm for the change to take effect.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With