Open cdlhao opened 1 year ago
the platform is Anaconda3-2021.11-Windows-x86_64
Plz check the reason thanks.
I had the same issue. Created a new env. Installed the specific versions in the requirements and it worked without problems.
Hello!
Sorry for my ultra late reply. Thank you @NicoAlvear for helping. @cdlhao do you still have troubles with the library?
@alfonsosemeraro I just installed the library and have the issue above. `>>> emotions = {'joy': 0.6, ... 'trust': 0.4, ... 'fear': 0.1, ... 'surprise': 0.7, ... 'sadness': 0.1, ... 'disgust': 0.5, ... 'anger': 0.4, ... 'anticipation': 0.6}
plutchik(emotions) Traceback (most recent call last): File "
", line 1, in File "/home/pp/anaconda3/envs/playground/lib/python3.8/site-packages/pyplutchik/pyplutchik.py", line 1284, in plutchik _neutral_central_circle(ax) File "/home/pp/anaconda3/envs/playground/lib/python3.8/site-packages/pyplutchik/pyplutchik.py", line 433, in _neutral_central_circle ax.add_patch(descartes.PolygonPatch(c, fc='white', ec=(.5, .5, .5, .3), alpha=1, zorder = 15)) File "/home/pp/anaconda3/envs/playground/lib/python3.8/site-packages/descartes/patch.py", line 87, in PolygonPatch return PathPatch(PolygonPath(polygon), **kwargs) File "/home/pp/anaconda3/envs/playground/lib/python3.8/site-packages/descartes/patch.py", line 62, in PolygonPath vertices = concatenate([ File "/home/pp/anaconda3/envs/playground/lib/python3.8/site-packages/descartes/patch.py", line 63, in concatenate([asarray(t.exterior)[:, :2]] + IndexError: too many indices for array: array is 0-dimensional, but 2 were indexed `
Hello @pahalie,
There must have been an update with either shapely or descartes. I can't figure out how to fix it right now, but I know for sure that older versions of shapely/descartes work well.
A temporary solution would be the one provided by @NicoAlvear: just open a new virtual environment and install the exact versions of the packages as listed in requirements.txt
I will work on fixing it asap, but I can't promise I'll be super quick.
Alfonso
Hi,
I'm experiencing the same problem as @NicoAlvear and @pahalie, but I have tried installing the older versions of shapely and descartes and the problem persists. Is there another way to get around this issue?
Hello @charquero, I'm sorry to hear this. Can you report exactly what package versions you have installed on your virtualenv?
Hey @alfonsosemeraro, I'm having the same issue. My python version is 3.8.16 with
Tried to install version in requirement.txt, but got errors with shapely and numpy when installing.
Hey @alfonsosemeraro, I'm having the same issue. My python version is 3.8.16 with
- shapely [required: Any, installed: 2.0.1]
- numpy [required: >=1.14, installed: 1.24.3]
- matplotlib [required: Any, installed: 3.7.1]
- descartes [required: Any, installed: 1.1.0]
Tried to install version in requirement.txt, but got errors with shapely and numpy when installing.
Tried other versions and found a working one for me:
Here's a solution that worked for me. Modify your installation of descartes.
Around line 63 t.exterior
should be t.exterior.coords
vertices = concatenate([
concatenate([asarray(t.exterior.coords)[:, :2]] +
[asarray(r)[:, :2] for r in t.interiors])
for t in polygon])
Hey @alfonsosemeraro, I'm having the same issue. My python version is 3.8.16 with
- shapely [required: Any, installed: 2.0.1]
- numpy [required: >=1.14, installed: 1.24.3]
- matplotlib [required: Any, installed: 3.7.1]
- descartes [required: Any, installed: 1.1.0]
Tried to install version in requirement.txt, but got errors with shapely and numpy when installing.
Tried other versions and found a working one for me:
* Name: numpy, Version: 1.23.4 * Name: Shapely, Version: 1.8.5.post1 * Name: matplotlib, Version: 3.6.0 * Name: descartes, Version: 1.1.0
This solution worked for me too! Thank you very much!
Here's a solution that worked for me. Modify your installation of descartes.
lib/python3.10/site-packages/descartes/patch.py
Around line 63
t.exterior
should bet.exterior.coords
vertices = concatenate([ concatenate([asarray(t.exterior.coords)[:, :2]] + [asarray(r)[:, :2] for r in t.interiors]) for t in polygon])
Thanks, @esmarkowski.
I applied your solution, and it works like a charm. It saves me from installing specific versions of the impacted libraries.
Ideally, we shouldn't edit a third-party library like that. However, I dug into the descartes/patch.py
code to see what was happening. It is a Descartes object that is throwing the error. It's not the PyPlutchik code, so I expect they will fix the Descartes code eventually.
I avoid version-specific issues in my code to make updating to the latest versions easier. It's not always possible, but it's so worthwhile.
You may want to point it out to Descartes.
Works by using : pip install numpy==1.23.4 Shapely==1.8.5.post1 matplotlib==3.6.0 descartes==1.1.0
Works by using : pip install numpy==1.23.4 Shapely==1.8.5.post1 matplotlib==3.6.0 descartes==1.1.0
I had the same issue and solved it using this exactly versions.
However, the package shoud be considered broken. @alfonsosemeraro Are you planning to update it in the near future? Do you need help?
from pyplutchik import plutchik
emotions = {'joy': 0.6, 'trust': 0.4, 'fear': 0.1, 'surprise': 0.7, 'sadness': 0.1, 'disgust': 0.5, 'anger': 0.4, 'anticipation': 0.6}
plutchik(emotions)
got following errors
IndexError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_5468/15410483.py in
10 'anticipation': 0.6}
11
---> 12 plutchik(emotions)
~\anaconda3\lib\site-packages\pyplutchik\pyplutchik.py in plutchik(scores, ax, font, fontweight, fontsize, show_coordinates, show_ticklabels, highlight_emotions, show_intensity_labels, ticklabels_angle, ticklabels_size, height_width_ratio, title, title_size, normalize) 1282 1283 # Draw inner white circle -> 1284 _neutral_central_circle(ax) 1285 1286
~\anaconda3\lib\site-packages\pyplutchik\pyplutchik.py in _neutral_central_circle(ax, r) 431 """ 432 c = sg.Point(0, 0).buffer(r) --> 433 ax.add_patch(descartes.PolygonPatch(c, fc='white', ec=(.5, .5, .5, .3), alpha=1, zorder = 15)) 434 435 return ax
~\anaconda3\lib\site-packages\descartes\patch.py in PolygonPatch(polygon, kwargs) 85 86 """ ---> 87 return PathPatch(PolygonPath(polygon), kwargs)
~\anaconda3\lib\site-packages\descartes\patch.py in PolygonPath(polygon) 60 "A polygon or multi-polygon representation is required") 61 ---> 62 vertices = concatenate([ 63 concatenate([asarray(t.exterior)[:, :2]] + 64 [asarray(r)[:, :2] for r in t.interiors])
~\anaconda3\lib\site-packages\descartes\patch.py in(.0)
61
62 vertices = concatenate([
---> 63 concatenate([asarray(t.exterior)[:, :2]] +
64 [asarray(r)[:, :2] for r in t.interiors])
65 for t in polygon])
IndexError: too many indices for array: array is 0-dimensional, but 2 were indexed