I am using xlwings for running a macro from Excel to plot histogram using python matplotlib but I get the following error when trying to run the python code to plot the histogram from excel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\adel.moustafa\dashboard\main.py", line 7, in <module>
from Modules import Plotter
File "c:\users\adel.moustafa\dashboard\Modules\Plotter.py", line 6, in <module>
import matplotlib.pyplot as plt
File "C:\Users\adel.moustafa\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 887, in <module>
cbook._get_data_path("matplotlibrc"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\adel.moustafa\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\cbook\__init__.py", line 559, in _get_data_path
return Path(matplotlib.get_data_path(), *args)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'matplotlib' has no attribute 'get_data_path'
This only happens when I try to run the python code from excel using macro, however if run the same code from Pycharm IDE it works fine and no error is produced.
I have looked for this error and what it means and reach the conclusion of that the error source may be due to conflict of matplotlib versions (one installed using conda and the other using pip). so I have completely removed install anaconda distribution using this guide after that I uninstall and reinstall matplotlib using pip but unfortunately that did not solve the problem. so, I continue to search and found similar posts to my case that advice by using a python virtual environment to solve the problem. so, I have done that but also with no result. finally I completely removed python from my system and reinstalled it but that did not solve the problem either. now, I really don't know what else to do or try!. so if any one could help it would much appreciated.
here is the list of packages installed on my machine
Package Version
--------------- --------
contourpy 1.0.7
cycler 0.11.0
fonttools 4.38.0
kiwisolver 1.4.4
matplotlib 3.6.3
numpy 1.24.1
packaging 23.0
pandas 1.5.3
Pillow 9.4.0
pip 22.3.1
pyparsing 3.0.9
python-dateutil 2.8.2
pytz 2022.7.1
pywin32 305
seaborn 0.12.2
setuptools 65.6.3
six 1.16.0
wheel 0.38.4
xlwings 0.28.9
and the python version
Python 3.11.1
finally here is the posts that I looked at.
post1
post2
post3
post4
post5
Related
I am trying to follow this video: https://www.youtube.com/watch?v=_UqmgHKdntU
I cloned the github repository, and then I downloaded the weight files. I also created a virtual environment with python 3.6.0 (because Python 3.9.2 was giving error due to incomaptibility with Tensorflow version 2.2 which was in the requirements.txt file)
However, when I tried to load the weights with the following command,
python load_weights.py
I am getting this error,
__version__ = __version_info__.__version__
AttributeError: 'version_info' object has no attribute '__version__'
I tried to find this a lot on Stackoverflow and other places on Google but could not find anything that worked for me.
The complete error is given below,
File "load_weights.py", line 4, in <module>
from yolov3_tf2.models import YoloV3, YoloV3Tiny
Traceback (most recent call last):
File "load_weights.py", line 4, in <module>
from yolov3_tf2.models import YoloV3, YoloV3Tiny
File "E:\Example4\Object-Detection-API\yolov3_tf2\models.py", line 23, in <module>
from .utils import broadcast_iou
File "E:\Example4\Object-Detection-API\yolov3_tf2\utils.py", line 5, in <module>
from seaborn import color_palette
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\seaborn\__init__.py", line 2, in <module>
from .rcmod import * # noqa: F401,F403
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
import matplotlib as mpl
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import cbook, rcsetup
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\rcsetup.py", line 28, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\fontconfig_pattern.py", line 15, in <module>
from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd,
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\pyparsing\__init__.py", line 130, in <module>
__version__ = __version_info__.__version__
AttributeError: 'version_info' object has no attribute '__version__'
One of the solutions on Stackoverflow told me to change pyparsing library, unknown version in python library pyparsing
Edit: I checked the pyparsing version using the command pip show pyparsing, which displayed the following results,
WARNING: Ignoring invalid distribution -ensorflow (e:\hassan\example4\object-detection-api\venv\lib\site-packages)
Name: pyparsing
Version: 3.0.7
Summary: Python parsing module
Home-page: https://github.com/pyparsing/pyparsing/
Author: Paul McGuire
Author-email: ptmcg.gm+pyparsing#gmail.com
License: MIT License
Location: e:\example4\object-detection-api\venv\lib\site-packages
Requires:
Required-by: matplotlib
After which I tried to install the pyparsing version 3.0.7 using the command pip install pyparsing==3.0.7, however I got this message,
Requirement already satisfied: pyparsing==3.0.7 in e:\example4\object-detection-api\venv\lib\site-packages (3.0.7)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'E:\Example4\Object-Detection-API\venv\Scripts\python.exe -m pip install --upgrade pip' command.
I also tried to uninstall the pyparsing and again install the specified version, but the problem still persisted.
Another solution asked me to also install the tensorflow-gpu which was given on the Github repository,
pip install -r requirements-gpu.txt
I tried this however this also did not work. I also tried to uninstall and install Tensorflow again, but again the same error persisted.
I also tried to upgrade my pip by using this,
python -m pip install --upgrade pip
This showed me the message that,
Requirement already satisfied: pip in e:\hassan\semester 8\research\example4\object-detection-api\venv\lib\site-packages (21.3.1)
However, at the end, it said that new version is still available (but it wouldn't install it, I don't know for what reason)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'E:\Example4\Object-Detection-API\venv\Scripts\python.exe -m pip install --upgrade pip' command.
According to one of the posts, upgrading pip solves the problem. I tried to upgrade but it neither upgraded the pip version nor did it solve my problem.
Can anyone help me solve this version error?
I am trying to work with the "oceansdb" package, and as a dependency it requires netCDF4. When I try to run anything related to oceansdb, I get an error:
File "C:/Users/Documents/starter.py", line 12, in <module>
import oceansdb
File "C:\Users\Anaconda3-64bit\lib\site-packages\oceansdb\__init__.py", line 8, in <module>
from oceansdb.woa import WOA
File "C:\Users\Anaconda3-64bit\lib\site-packages\oceansdb\woa.py", line 12, in <module>
import netCDF4
File "C:\Users\Anaconda3-64bit\lib\site-packages\netCDF4\__init__.py", line 3, in <module>
from ._netCDF4 import *
File "include\membuf.pyx", line 16, in init netCDF4._netCDF4
AttributeError: type object 'netCDF4._netCDF4._MemBuf' has no attribute '__reduce_cython__'
I have tried uninstalling and reinstalling netCDF4, then upgrading my cython version and doing the same uninstall/reinstall, both to no avail. I also tried uninstalling and reinstalling oceansdb. Everything has yielded the same error and I can't seem to find anyone else with the same issue.
I was getting a similar error. I think the key is the versions of the packages you are using.
I was using:
cftime 1.1.2
cython 0.28.5
hdf5 1.10.2
netcdf4 1.5.3
numpy 1.15.1
pandas 0.23.4
setuptools 40.2.0
and I got the error above.
With the packages below, all works great:
cftime 1.0.3.4
cython 0.28.5
hdf5 1.10.2
netcdf4 1.5.2
numpy 1.15.1
pandas 0.23.4
setuptools 40.2.0
I need to draw maps in High resolution in python. Basemap and basemap-data-hires are both installed, but basemap does not find the basemap-data-hires.
Both are installed as you can see from this conda list:
packages in environment at /home/paloma/anaconda3/envs/PAG2019:
Name Version Build Channel
basemap 1.2.0 py36h705c2d8_0 anaconda
basemap-data-hires 1.2.0 0 conda-forge
gst-plugins-base 1.14.0 hbbd80ab_1 anaconda
Suspecting a conflicting/wrong installation, I tried to re-install basemap-data-hires from anaconda and conda-forge, but to no avail.
Here is the import I use:
from mpl_toolkits.basemap import Basemap
Here is the error message I get:
Traceback (most recent call last):
File "./MakeGraphs.py", line 89, in <module>
lat_ts=0.5*(lats[0,0]+lats[-1,-1]),lat_0=0.5*(lats[0,0]+lats[-1,-1]),lon_0=0.5*(lons[0,0]+lons[-1,-1]))
File "/home/paloma/anaconda3/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py", line 1122, in __init__
self._readboundarydata('gshhs',as_polygons=True)
File "/home/paloma/anaconda3/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py", line 1236, in _readboundarydata
raise IOError(msg)
OSError: Unable to open boundary dataset file. Only the 'crude' and 'low',
resolution datasets are installed by default.
If you are requesting an, 'intermediate', 'high' or 'full'
resolution dataset, you may need to download and install those
files separately with
`conda install basemap-data-hires`.
Any idea anyone??
On closer look, there's probably a conflict between the CONDA_PREFIX of the environment:
$CONDA_PREFIX=/home/paloma/anaconda3/envs/PAG2019
and the basemap_datadir of basemap:
basemap_datadir=/home/paloma/anaconda3/
Does some know how to solve that?
For installing 'intermediate', 'high' or 'full' use the following command:
conda install -c conda-forge basemap-data-hires
Otherwise you will have 'crude' and 'low' only, installed by default.
As basemap went to look for the files in the directory of the base environment, installing basemap-data-hires in the base worked for me.
Quick and dirty, but effective.
I'm facing this issue while trying to use pandas package. I have installed numpy 1.9.0 and installed dateutil 2.5.0 using the command
pip install python-dateutil==2.5.0. Still I see this error.
Is there any other way to install dateutil? And this is related only to pandas package
Traceback (most recent call last): import pandas as pd File
"/Users/xyz/Library/Python/2.7/lib/python/site-packages/pandas/init.py",
line 23, in
from pandas.compat.numpy import * File "/Users/xyz/Library/Python/2.7/lib/python/site-packages/pandas/compat/init.py",
line 422, in
raise ImportError('dateutil 2.5.0 is the minimum required version') ImportError: dateutil 2.5.0 is the minimum required version
I had this same issue using the newest pandas version, try downgrading to pandas 0.22.0 which fixed my issue
The issue was resolved by installing python 3.6. There is a version compatibility issue between pandas package and earlier version of Python
Check what code you used to run the program
I first tried running the file with: "python file.py"
but I got an error. so try running the file with
python3 file.py
(put your file name instead of the file)
This fixed the error and I was able to run the file
Am new to progamming and Python, i keep getting the error below when i run my program. Someone advised i should use pip to solve it. But cant pip get installed using the cmd. Though i suceeded using Powershell but still cant make it work. How do i solve this, any tips will go along way. Thanks
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from satmc import satmc
File "C:\Python27\starb_models_grid1\satmc.py", line 3, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 110, in <module>
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
Am using version 2.7.3
You need to install various packages to get numpy working correctly.
libsvm-3.17.win32-py2.7
pyparsing-2.0.1.win32-py2.7
python-dateutil-2.2.win32-py2.7
pytz-2013.9.win32-py2.7
six-1.5.2.win32-py2.7
scipy-0.13.3.win32-py2.7
numpy-MKL-1.8.0.win32-py2.7
Matplotlib
Download all the binaries from this link and install and then you will have a working numpy installation.
You're probably looking for:
pip install python-dateutil
The error states that you are missing Dateutil.
This could mean that you did not install Dateutil with pip install python-dateutil or your way to install Python modules. But if you did your pip install and still get the same error it could also mean that DateUtil is installed in a folder where your Python distribution does not expect it.
In my case (Mac OSX) I installed pip with Brew http://brew.sh/. That pip will install the modules in: /usr/local/lib/python2.7/site-packages/
However the standard Mac OSX Python distribution will look for modules in /Library/Python/2.7/site-packages/
Your folders could be different of course, but you can check where Python looks for modules with:
import sys
print sys.path
Check this and see if one of the directories in the list contains the directory where dateutil is installed.
If not add a PYTHONPATH environment variable: Like: PYTHONPATH=/usr/local/lib/python2.7/site-packages/ or the folder where your dateutil is installed
I did pip install python-dateutil, but kept getting the same error. I got past that error by installing from http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil
Look for the Matplotlib section and install the dependencies you don't have.
Matplotlib is a 2D plotting library.
Requires numpy, dateutil, pytz, pyparsing, six, setuptools, and optionally pillow, pycairo, tornado, wxpython, pyside, pyqt4, ghostscript, miktex, ffmpeg, mencoder, avconv, or imagemagick.