Install PyQt4 via conda for caffe model - pyqt4

When I try to run the SEC caffe model on from here: https://github.com/kolesman/SEC
I geht the error: ImportError: No module named PyQt4
python demo.py --model SEC.caffemodel --image /data/out/dataset/center/1475186965759787059.jpg --smooth --output result.png
Traceback (most recent call last):
File "demo.py", line 2, in <module>
import pylab
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/matplotlib/pylab.py", line 274, in <module>
from matplotlib.pyplot import *
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in <module>
from .backend_qt5 import QtCore
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 31, in <module>
from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_compat.py", line 137, in <module>
from PyQt4 import QtCore, QtGui
ImportError: No module named PyQt4
In this stackoverflow thread they just mention that you can run
conda install pyqt
which results in the following output:
conda install pyqt
Fetching package metadata .......
Solving package specifications: ..........
# All requested packages already installed.
# packages in environment at /home/ec2-user/anaconda2:
#
pyqt 5.6.0 py27_0
Which indicates that I have version 5.6 and not version 4. But I could not find any solution how to downgrade to pyqt4.

so you can Uninstall pyqt5 and download PyQt4 and installed manually
The second option is to modify the code and replace PyQt4 by pyqt5 just pay attention to one thing that the classes in pyqt5 are the same but the irritation is bit different so you may get that specific model doesn't exist in this case check on manual of pyqt5 and fix it
I hope my answer is clear

It looks like the latest version of anaconda forces install of pyqt5.6 over any pyqt build, which will be fatal for your applications. In a terminal, Try:
conda install --channel https://conda.anaconda.org/conda-forge pyqt
conda install -c anaconda pyqt=4.11.4
It will prompt to downgrade conda client. After that, it should be good.

Related

Problem with matplotlib - python 3.11: ImportError: DLL load failed while importing _path:

I have the same case which is mentioned in:
Problem with matplotlib when imported with python 3.9: ImportError: DLL load failed while importing _path:
but i have one version of python installed (version 3.11) and the path is correct. I do not know how to solving this problem. Could you help me?
I checked if the library is installed in the correct directory. It's correct. The numpy module works and is in the same directory as matplotlib. I have one version installed - python 3.11. I work with Python's IDLE.
Whole bug is:
"
Traceback (most recent call last):
File "C:/Users/Admin/AppData/Local/Programs/Python/Python311/simple-plot.py", line 1, in <module>
import matplotlib
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: DLL load failed while importing _path: Nie można odnaleźć określonego modułu.
"
I had a similar issue.
Official Author's Recommendation
https://github.com/matplotlib/matplotlib/issues/24704
The issue can be worked around by using an additional dependency:
pip install msvc-runtime
You can specify this in your requirements like so:
msvc-runtime; sys_platform == 'win32'
Therefore it will only install for Window's users.
Further options
The above didn't work in my case. My context is that I am using a Docker container based on the windowsservercore-ltsc2022 image.
Instead I installed the vcredist manually (I've included a more verbose set of steps as I use chocolatey. Do refer to the latest chocolatey website for any updated install instructions):
# Use powershell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Install chocolatey
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install matplotlib workaround
# https://github.com/matplotlib/matplotlib/issues/24704 # Remove after matplotlib 3.7
RUN choco install -y --limit-output vcredist-all

module 'matplotlib' has no attribute 'artist', Matplotlib 3.0.0 [duplicate]

Using Windows 10, anaconda as a package manager. I have a base environment running python 3.7 where matplotlib works fine. When I create a new environment and install both keras and matplotlib, I start to run into problems:
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\__init__.py", line 1111, in <module>
rcParamsOrig = RcParams(rcParams.copy())
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\__init__.py", line 891, in __getitem__
from matplotlib import pyplot as plt
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\pyplot.py", line 32, in <module>
import matplotlib.colorbar
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\colorbar.py", line 40, in <module>
import matplotlib._constrained_layout as constrained_layout
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\_constrained_layout.py", line 52, in <module>
from matplotlib.legend import Legend
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\legend.py", line 43, in <module>
from matplotlib.offsetbox import HPacker, VPacker, TextArea, DrawingArea
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\offsetbox.py", line 33, in <module>
from matplotlib.image import BboxImage
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\image.py", line 19, in <module>
from matplotlib.backend_bases import FigureCanvasBase
File "C:\...\Anaconda3\envs\keras_env\lib\site-packages\matplotlib\backend_bases.py", line 46, in <module>
from matplotlib import (
ImportError: cannot import name 'get_backend'
Any suggestions? This is a fresh installation of conda. All I've done to get here is run conda create --name keras_env keras matplotlib, enter the environment, and try to import matplotlib. These are the packages conda installs:
## Package Plan ##
environment location: C:\...\Anaconda3\envs\keras_env
added / updated specs:
- keras
- matplotlib
The following NEW packages will be INSTALLED:
_tflow_select: 2.2.0-eigen
absl-py: 0.5.0-py36_0
astor: 0.7.1-py36_0
blas: 1.0-mkl
ca-certificates: 2018.03.07-0
certifi: 2018.10.15-py36_0
cycler: 0.10.0-py36h009560c_0
freetype: 2.9.1-ha9979f8_1
gast: 0.2.0-py36_0
grpcio: 1.12.1-py36h1a1b453_0
h5py: 2.8.0-py36h3bdd7fb_2
hdf5: 1.10.2-hac2f561_1
icc_rt: 2017.0.4-h97af966_0
icu: 58.2-ha66f8fd_1
intel-openmp: 2019.0-118
jpeg: 9b-hb83a4c4_2
keras: 2.2.4-0
keras-applications: 1.0.6-py36_0
keras-base: 2.2.4-py36_0
keras-preprocessing: 1.0.5-py36_0
kiwisolver: 1.0.1-py36h6538335_0
libpng: 1.6.35-h2a8f88b_0
libprotobuf: 3.6.0-h1a1b453_0
markdown: 3.0.1-py36_0
matplotlib: 3.0.0-py36hd159220_0
mkl: 2019.0-118
mkl_fft: 1.0.6-py36hdbbee80_0
mkl_random: 1.0.1-py36h77b88f5_1
numpy: 1.15.3-py36ha559c80_0
numpy-base: 1.15.3-py36h8128ebf_0
openssl: 1.0.2p-hfa6e2cd_0
pip: 10.0.1-py36_0
protobuf: 3.6.0-py36he025d50_0
pyparsing: 2.2.2-py36_0
pyqt: 5.9.2-py36h6538335_2
python: 3.6.7-h33f27b4_0
python-dateutil: 2.7.3-py36_0
pytz: 2018.5-py36_0
pyyaml: 3.13-py36hfa6e2cd_0
qt: 5.9.6-vc14h1e9a669_2
scipy: 1.1.0-py36h4f6bf74_1
setuptools: 40.4.3-py36_0
sip: 4.19.8-py36h6538335_0
six: 1.11.0-py36_1
sqlite: 3.25.2-hfa6e2cd_0
tensorboard: 1.11.0-py36he025d50_0
tensorflow: 1.11.0-eigen_py36h346fd36_0
tensorflow-base: 1.11.0-eigen_py36h45df0d8_0
termcolor: 1.1.0-py36_1
tornado: 5.1.1-py36hfa6e2cd_0
vc: 14.1-h0510ff6_4
vs2015_runtime: 14.15.26706-h3a45250_0
werkzeug: 0.14.1-py36_0
wheel: 0.32.2-py36_0
wincertstore: 0.2-py36h7fe50ca_0
yaml: 0.1.7-hc54c509_2
zlib: 1.2.11-h8395fce_2
This issue has been reported here and has been fixed here. The fix will be available in matplotlib 3.0.1, which is scheduled to be release within the next few days.
Until then you may either use python <= 3.6.6 with matplotlib 3.0.0. Or you may use matplotlib 2.2.3 or you may try the fix proposed in the linked issue, namely to create a matplotlibrc file in one of the paths where matplotlib would find it.
Try this:
pip uninstall matplotlib
python -m pip install --upgrade pip
pip install matplotlib
Worked perfectly for me
pip uninstall matplotlib
pip install --upgrade matplotlib
works perfectly!
Simply install the appropriate version:
run this in your Jupyter notebook
!pip3 uninstall matplotlib -y
!pip3 install matplotlib==3.0.1
or in terminal:
pip3 uninstall matplotlib -y
pip3 install matplotlib==3.0.1

Import Seaborn Error - Numpy_MKL (Python Script)

I coded in jupyter-notebook, fetching data from mysqlserver and then downloaded it as a python script because I want to implement it in my website using cronjob. So when I run the Python script, I'm getting this error:
import seaborn as sns
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\palettes.py", line 12, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\utils.py", line 7, in <module>
from scipy import stats
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
I tried to install numpy+mkl .whl file from this link: Numpy+MKL, this (numpy‑1.15.1+mkl‑cp37‑cp37m‑win_amd64.whl) package, but it showed, not supported when I tried to install it.
The following solution worked out:
Solution:
If you are using windows make sure you install numpy+mkl instead of just numpy.
If you have already installed scipy and numpy, uninstall then using "pip uninstall scipy" and "pip uninstall numpy"
Now download scipy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy (appropriate version for your python and system)
and install using "pip install scipy‑1.1.0‑cp36‑cp36m‑win_amd64.whl" (Please install from the list according to your system config)
Your numpy and Scipy both should work now.
These binaries by Christoph Gohlke makes it very easy to install python packages on windows. But make sure you download all the dependent packages from there.
Reference: 4th answer of this question ImportError: cannot import name NUMPY_MKL

import fiona : ImportError: cannot import name 'calc_gdal_version_num'

I'm trying to install geopandas.
Whether I do one of these :
conda install -c conda-forge geopandas
# or
conda install -c conda-forge fiona
# or
pip3 install Fiona‑1.7.9‑cp36‑cp36m‑win_amd64.whl # downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona
When I try either import geopandas or import fiona, I get the following error :
File "<ipython-input-229-c9ee6bd24dbc>", line 1, in <module>
import geopandas
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\__init__.py", line 4, in <module>
from geopandas.io.file import read_file
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\io\file.py", line 3, in <module>
import fiona
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\__init__.py", line 69, in <module>
from fiona.collection import Collection, BytesCollection, vsi_path
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\collection.py", line 11, in <module>
from fiona.ogrext import (
ImportError: cannot import name 'calc_gdal_version_num'
Any idea on how to solve this ?
(I'm on windows 7 64 bit by the way, in case it's relevant)
EDIT :
It seems this behavior happens only in the IPython console of Spyder (v3.1.4). It doesn't happen when using the python3 command line in the terminal, or the python console of Spyder. I would still love a fix for the IPython console of Spyder, the python console in Spyder is reaaaally slow.

import matplotlib.pyplot failing: _tkagg.pyd not found but IS in the directory of calling module

Python 3.4
Windows 8.1
Installed modules:
matplotlib 1.3.1 for py 3.4
numpy-MLK 1.9.0b1 for py 3.4
dateutil 2.2 for py 3.4
six 1.7.3 for py 3.4
tcl
tkinter
Also msvcp71.dll is in C:\Windows\System32 (installation docs said it needed to be)
Upon running:
import matplotlib.pyplot as plt
I get the following error message:
Traceback (most recent call last):
File "<pyshell#284>", line 1, in <module>
import matplotlib.pyplot as plt
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\backends\__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 11, in <module>
import matplotlib.backends.tkagg as tkagg
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\backends\tkagg.py", line 2, in <module>
from matplotlib.backends import _tkagg
ImportError: DLL load failed: The specified module could not be found.
Point being: Python\lib\site-packages\matplotlib\backends\tkagg.py is trying to
execute
from matplotlib.backends import _tkagg
but failing to do so. However _tkagg.pyd file does exist in the directory
Python\lib\site-packages\matplotlib\backends
Why is this not working then?
I know this is an old thread, but I just ran into the same problem and I found a solution, so I decided to answer it.
By taking a look at matplotlib install documentation, it says:
For Python 3.5 the Visual C++ Redistributable for Visual Studio 2015 needs to be installed.
I installed it's 64 bit version from it's Microsoft website (as I use 64 bit Python 3.6.3, and now the import works fine.
I hope it helps anyone that may face the same issue in the future.

Resources