ImportError with "Import PyQt5.QtSql " - pyqt5

I am attempting to
from PyQt5.QtSql import QSqlDatabase, QSqlQuery
and am receiving this error:
from PyQt5.QtSql import QSqlDatabase, QSqlQuery
ImportError: No module named 'PyQt5.QtSql'
I haven't yet ran into an import problem with other PyQt5 modules. Is the QtSql module installed separately?
thanks,

There is a similar problem described at https://github.com/ghostop14/sparrow-wifi/issues/1
Solution described there is to run command
apt-get install python3-pyqt5.qtsql

Related

import yfinance issue - numpy dependency problem? Need to uninstall then reinstall numpy every time. Code works from CLI, but not in PyCharm

I am trying to use the yfinance module. I have a venv set up. If I run my code from the command line it works. If I run it inside PyCharm it throws this import error. Doing pip uninstall -y numpy and then pip install numpy fixes the problem, but I have to do this every day. I'm very confused on what is the issue. Anyone have any tips?
It is failing at literally the first line of code which is the import yfinance line. Here is the traceback:
Traceback (most recent call last):
File "/Users/MikeGuglielmo/Desktop/python_code.py/python_distilled/practice.py/main.py", line 1, in
import yfinance as yf
File "/Users/MikeGuglielmo/Desktop/python_code.py/options_project/venv/lib/python3.9/site-packages/yfinance/init.py", line 23, in
from .ticker import Ticker
File "/Users/MikeGuglielmo/Desktop/python_code.py/options_project/venv/lib/python3.9/site-packages/yfinance/ticker.py", line 27, in
import pandas as _pd
File "/Users/MikeGuglielmo/Desktop/python_code.py/options_project/venv/lib/python3.9/site-packages/pandas/init.py", line 16, in
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
The Python version is: Python3.9 from "/Users/MikeGuglielmo/Desktop/python_code.py/options_project/venv/bin/python"
The NumPy version is: "1.23.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'

rqt_graph pyqt binding of qt_gui_cpp library

I am using ROS-melodic in ubuntu 18.04 LTS. I am getting this error:
Could not import "pyqt" bindings of qt_gui_cpp library - so C++ plugins will not be available:
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui_cpp/cpp_binding_helper.py", line 43, in <module>
from . import libqt_gui_cpp_sip
ImportError: dynamic module does not define module export function (PyInit_libqt_gui_cpp_sip)
however I have installed pyqt5 and pydot manually, rqt_graph shows up but with this warning. I want to know what can I do to get it right? Is this going to be problem in future? Now rqt_graph is loading but I don't know if this will mess up/create lacking in the graph?
Try uninstalling double packages if any using
pip3 uninstall PyQt5-sip PyQt5
Then try importing it in python3 to check if any other version is there.
If the import is successful then try running the command again
rosrun rqt_graph rqt_graph
if still some error exists install
pip3 install PyQt5==5.12

How to fix 'cannot import etree' error while executing rosrun "file

I wanted to run a python file in which I imported Lxml, but I got this error although I installed the Lxml package:
ImportError: cannot import name 'etree'
Is there a way to fix this please?

I want to use pandas2ri in JUPYTER but tzlocal issue?

Everytime I try to import the pandas2ri in jupyter, python interface:
from rpy2.robjects import pandas2ri
I get the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-28-cc52694d111a> in <module>()
----> 1 from rpy2.robjects import pandas2ri
/Users/sondosayyash/anaconda/lib/python3.6/site-packages/rpy2/robjects/pandas2ri.py in <module>()
21 import numpy
22 import pytz
---> 23 import tzlocal
24 import warnings
25
ModuleNotFoundError: No module named 'tzlocal'
I tried to use
from dateutil.tz import tzlocal
but that didn't seem to fix the issue.
I've already installed tzlocal and it is on my computer. When I import pandas2ri on ipython, there is no problem.. the problem only occurs when calling in the jupyter environment.
this is the message I get when I try to install tzlocal again:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: tzlocal in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.5.1)
Requirement already satisfied: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from tzlocal) (2017.2)
I had a similar issue when running rpy2 in Jupyter. I did not have the package installed previously. I just installed the package and the error went away. You can try installing the package again to see if it helps resolve your issue.
pip install tzlocal
I must add that I am using Python 3.6.8 not 2.7
If using conda:
conda install tzlocal
worked.
I had a similar issue as yours. It turns out that my local lib did not have the tzlocal package. So I installed the package through Anaconda prompt:
pip install tzlocal
And the issue is gone.

ImportError: Install xlrd >= 0.9.0 for Excel support when using pd.readexcel to read .xlsx file : never happened before

Something strange is going on. Just today when trying to read in a dataframe from an xlsx file:
import pandas as pd
df = pd.read_excel('vlnew.xlsx',sheet_name='Sheet1')
I am getting the following error:
ImportError: Install xlrd >= 0.9.0 for Excel support
I am fully aware that plain and simple the instructions are to install xlrd, but I should not have to install xlrd when I was never getting this error before, and also, xlrd only applies to the old .xls file format. I am using .xlsx.
I can't understand why today all of a sudden this error is popping up. This is very strange indeed, at least to me.
Update:
When I execute this script in the Spyder IDE, I do not get the xlrd import error, but just today I ran this script in the Conda command prompt and only then does it report the xlrd error. Why are there inconsistencies between the Conda command prompt and Spyder IDE?
Try writing following command into the terminal
pip install xlrd
And then import the xlrd alongside with pandas
import xlrd and import pandas as pd
I was getting an error "ImportError: Install xlrd >= 1.0.0 for Excel support" on Pycharm for below code
import pandas as pd
df2 = pd.read_excel("data.xlsx")
print(df2.head(3))
print(df2.tail(3))
Solution : pip install xlrd
It resolved error after using this.
Also no need to use "import xlrd" in program
(2021.01.18)
NOTICE: the current version of "xlrd" reads only ".xls" files
to read ".xlsx" files install openpyxl package.
Just do it in your phyton frame (my is "repl.it") writing
import xlrd
or
openpyxl_
NOTICE: the current version of "xlrd" reads only ".xls" files
As mentioned by you and others correctly that xlrd needs to be installed, for using read_excel we require xlrd package.
This might be one of the possibility of compatibility difference between spyder and conda is that you might be using different conda environments for Spyder and prompt, one of which might contain xlrd package and other did not this has happens usually when we use different virtual environments for our work , it has happened to me many times.
You should try
pip install --upgrade xlrd
juste type
pip install xlrd
and use it like this
import xlrd
import pandas as pd
data=pd.read_excel('titanic3.xls')