Python Geopandas throwing "Shell is not a Linear Ring" Error - python

I am new to python and I am trying to open a shape file but when I open the file I am getting a message that says "Shell is not a Linear Ring" Message when I try and open it via command line. My code is two lines long so I am not really sure whats going on here...
Code:
import geopandas as gpd
gdp.read_file("tl_2016_17_tract.shp")
Error:
"Shell is not a LinearRing"
I've also tried opening the shape file with R and QGIS and both worked fine. I think it might have something to do with my installation of python because I was having some issues with that earlier. I can't find a good explanation of the error "Shell is not a LinearRing" anywhere!
Thanks for the help!

A user with the exact same problem said:
I resolved this issue - I believe it had to do with geopandas and how it was installed. I resolved it by using:
conda remove geopandas
I originally installed via conda-forge channel
and then installing via pip:
pip install geopandas
I also went through and installed some packaged via homebrew, but I am not sure if that made a difference.
Source

Related

Error exporting styled dataframes to image, "SyntaxError: not a PNG file" using dataframe_image

I've been using dataframe_image for a while and have had great results so far. Last week, out of a sudden, all my code containing the method dfi.export() stopped working with this error as an output
raise SyntaxError("not a PNG file")
File <string>
SyntaxError: not a PNG file
I can export the images passing the argument table_conversion='matplotlib' but they do not come out styled...
This is my code:
now = str(datetime.now())
filename = ("Extracciones-"+now[0:10]+".png")
df_styled = DATAFINAL.reset_index(drop=True).style.apply(highlight_rows, axis=1)
dfi.export(df_styled, filename,max_rows=-1)
IMAGEN = Image.open(filename)
IMAGEN.show()
Any clues on why this just suddenly stopped working?
Or any ideas to export dataframes as images (not using html)?
These were the outputs i used to get:
fully styled dataframe images
and this is the only thing I can get right now
Thank you in advance
dataframe_image has a dependency on Chrome, and a recent Chrome update (possibly v109 on 2013-01-10) broke dataframe_image. v0.1.5 was released on 2023-01-14 to fix this.
pip install --upgrade dataframe_image
pip show dataframe_image
The version should now be v0.1.5 or later, which should resolve the problem.
Some users have reported still having the error even after upgrading. This could be due to upgrading the package in the wrong directory (due to multiple installations of python, pip, virtual envs, etc). The reliable way to check the actual version of dataframe_image that the code is using, is to add this debugging code to the top of your python code:
import pandas as pd
import dataframe_image as dfi
from importlib.metadata import version
print(version('dataframe_image'))
df = pd.DataFrame({'x':[1,2]})
dfi.export(df, 'out.png')
exit()
Also check chrome://version/ in your Chrome browser.
I had the same issue, and we finally figured it out; looks like the new release of dataframe_image on 1/14 broke something on the previous version.
We upgraded the package and the issue was resolved.
pip install -u dataframe_image
I fixed this issue.
It was related to resources that are busy in the background and chrome can't use these resources.
https://github.com/dexplo/dataframe_image/pull/70
please update the library to version v0.1.5
you can do it via pip :
python -m pip install --upgrade dataframe-image
Good luck.

Spyder is unable to show the variable you are trying to view

I am using Spyder 4.1.5 with Python 3.8.5 with Anaconda
When trying to show the content of a variable in Spyder i get the following error
Spyder is unable to show the variable you are trying to view because the module spydercustomize was not found in your Spyder environment. Please install this package in your Spyder environment.
A simple pip install spydercustomize does not work
I don't even know why it is missing. I think the problem occured the first time when I tried to update Spyder. A reinstallation of Anaconda didn't help either.
My Google skills were not good enough to find any solution. I only find problems where variables don't show in the variable explorer. But that is not my problem.
Btw, built in classes like lists or dicts can be displayed, custom classes can't.
I appreciate your help!
EDIT
After updating to Spyder 4.2.0 I got the following error:
Spyder was unable to retrieve the value of this variable from the
console.
The error message was: An error occured, see the console.
Note: Please don't report this problem on Github, there's nothing to
do about it.
Console is empty
Looks like spydercustomize is part of a package called spyder-kernels. Maybe try:
$ pip install spyder spyder-kernels --upgrade

ModuleNotFoundError: No module named 'mlxtend'

Hello Everyone,
I have an issue I have to immediately deal with it. I installed mlxtend and used the library for apriori(market research). In my first attempt it worked then next day I tried to update it with new data but it gives exactly this error ModuleNotFoundError: No module named 'mlxtend'. And I read everywhere to find where my mistake is? Sadly, I couldn't find it. I updated my mlxtend to current version however, again I faced with the exact, same problem. When I try to install mlxtend I got this as it is expected "Requirement already satisfied". I would appreciate and be glad if you have any suggestions? By the way, thanks to everyone who read this.
Are you installing it in the Conda shell or somewhere else? To ensure it gets installed in the correct environment type
%pip install mlxtend
from within the Jupyter notebook (in a cell at the top) that you are working in and execute that cell.
If it installs successfully you can comment out that cell or remove it.

Trying to open shapefiles

I have a number of companion files for a shapefile - .cpg, .dbf, .prj, .sbn, .sbx, .shp, .rtree, .shx
I have tried downoading a number of free softwares that open shapefiles such as TatukGIS viewer and DBF Reader Plus but with no luck.
I've attempted to open them in Python as I read this article:
http://www.acgeospatial.co.uk/geopandas-shapefiles-jupyter/
I'm having trouble installing geopandas however. I get this error when I try to run:
I've looked into these errors and tried using upgrade setup tool
Totally lost, have no idea what this error means when I look it up
As to you original question, try QGIS software. Among lots of features it surely can open Shapefile as well as many other geospatial formats.
As to the error you've posted, it's related to user permissions and was already answered, e.g. here Access is denied when trying to pip install a package on Windows.
Apparently geopandas is notoriously difficult to install, especially on Windows. To install geopandas, first install Conda, open the Anaconda Prompt as administrator and type:
conda install -c conda-forge geopandas
Found the answer on here:
https://www.reddit.com/r/gis/comments/as5rze/what_does_this_geopandas_installation_error_mean/
You can then use geopandas to open shapefiles

Tornado.access:500 POST error with IPython 2.0.0 on Python 3.3.5

I keep getting an error when trying to run code from one of my IPython notebooks (the notebooks themselves open up fine, I'm just unable to run any code and view the output).
The complete error is:
ERROR:tornado.access:500 POST /api/sessions (127.0.0.1) 13.01ms referrer=http://127.0.0.1:8888/notebooks/untitled0.ipynb.
I'm running Python 3.3.5, IPython 2.0.0 via an install from easy_install on a windows 8 machine.
I tried reinstalling (uninstall via pip, reinstall via easy_install) the tornado package, IPython, it was of no use.
Any help is greatly appreciated, thank you.
When I used anaconda, I met a similar problem .
Try
pip install simplejson
This works for me
This page talks about a similar problem and solution.
https://github.com/ipython/ipython/issues/1966/
Good Luck!!!
I was using Holoviews package in the IPynb and I was caught by similar error. Then I found that if try to plot a dataframe in the server rather than a "Series", this error shows up. I dont know thw complete reason for this, but to all those who are getting the similar error,
kindly change your data to Series and then plot it in server
Hope it works for you too.

Categories

Resources