Closed bafleck closed 3 years ago
Have you installed pyshp? It may be related to the shapefile reader/writer.
I have pyshp installed: Name: pyshp Version: 2.1.3
Barbara
On Wed, 21 Jul 2021 at 16:30, langevin-usgs @.***> wrote:
Have you installed pyshp? It may be related to the shapefile reader/writer.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/modflowpy/flopy/issues/1156#issuecomment-884236260, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQX2EVOPADIXRICIE7CJID3TY3KWTANCNFSM5AXJBYBA .
We can't reproduce this error on our end. The only code that actually evaluates the shapefile version is evaluating shapefile.__version__
not shapefile.version
.
Are you running this code from autotest/t075_ugridtests.py
?
maximum_area = 30000.0
extent = (214270.0, 221720.0, 4366610.0, 4373510.0)
domainpoly = [
(extent[0], extent[2]),
(extent[1], extent[2]),
(extent[1], extent[3]),
(extent[0], extent[3]),
]
tri = Triangle(maximum_area=maximum_area, angle=30, model_ws=tpth)
tri.add_polygon(domainpoly)
tri.build(verbose=False)
verts = [[iv, x, y] for iv, (x, y) in enumerate(tri.verts)]
iverts = tri.iverts
xc, yc = tri.get_xcyc().T
ncpl = np.array([len(iverts)])
g = UnstructuredGrid(
vertices=verts,
iverts=iverts,
ncpl=ncpl,
xcenters=xc,
ycenters=yc,
)
assert len(g.grid_lines) == 8190
assert g.nnodes == g.ncpl == 2730
Yes, the error comes at: tri.add_polygon(domainpoly)
def test_triangle_unstructured_grid(): maximum_area = 30000.0 extent = (214270.0, 221720.0, 4366610.0, 4373510.0) domainpoly = [ (extent[0], extent[2]), (extent[1], extent[2]), (extent[1], extent[3]), (extent[0], extent[3]), ] tri = Triangle(maximum_area=maximum_area, angle=30, model_ws=tpth) tri.add_polygon(domainpoly)
Exception has occurred: AttributeError
-
module 'shapefile' has no attribute 'version'
File "/Users/Barbara/modflow_playground/flopy/misc/triangle_example.py",
line 22, in test_triangle_unstructured_grid tri.add_polygon(domainpoly) File
"/Users/Barbara/modflow_playground/flopy/misc/triangle_example.py", line
46, in
On Thu, 22 Jul 2021 at 17:23, jdhughes-usgs @.***> wrote:
We can't reproduce this error on our end. The only code that actually evaluates the shapefile version is evaluating shapefile.version not shapefile.version.
Are you running this code from autotest/t075_ugridtests.py?
maximum_area = 30000.0 extent = (214270.0, 221720.0, 4366610.0, 4373510.0) domainpoly = [ (extent[0], extent[2]), (extent[1], extent[2]), (extent[1], extent[3]), (extent[0], extent[3]), ] tri = Triangle(maximum_area=maximum_area, angle=30, model_ws=tpth) tri.add_polygon(domainpoly) tri.build(verbose=False) verts = [[iv, x, y] for iv, (x, y) in enumerate(tri.verts)] iverts = tri.iverts xc, yc = tri.get_xcyc().T ncpl = np.array([len(iverts)]) g = UnstructuredGrid( vertices=verts, iverts=iverts, ncpl=ncpl, xcenters=xc, ycenters=yc, ) assert len(g.grid_lines) == 8190 assert g.nnodes == g.ncpl == 2730
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/modflowpy/flopy/issues/1156#issuecomment-885001218, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQX2EVPMTOKJLYPHQXSWCNDTZAZWZANCNFSM5AXJBYBA .
We can run the same autotest on my machine without any problems. Does this work in a python interpreter?
python
>>> import shapefile
>>> shapefile.__version__
I can reproduce the error if I have a file called shapefile.py
with any function in it in the same directory as the script I am running. If you do have such a file you need to rename the script to something else.
Yes, many thanks this was the reason. Barbara
On Thu, 22 Jul 2021 at 21:32, jdhughes-usgs @.***> wrote:
I can reproduce the error if I have a file called shapefile.py with any function in it in the same directory as the script I am running. If you do have such a file you need to rename the script to something else.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/modflowpy/flopy/issues/1156#issuecomment-885178668, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQX2EVOUY5XUZG54TEZMCBDTZBW6TANCNFSM5AXJBYBA .
I tried to run testscript 'test_triangle_unstructured_grid()' and get the following Error:
Exception has occurred: AttributeError module 'shapefile' has no attribute 'version'
on 15. jul. 2021 I downloaded the program 'triangle' for mac with date: 18.Feb.2021 I copied the program 'triangle' to /usr/bin
I use the following versions: numpy version: 1.18.5 matplotlib version: 3.2.2 flopy version: 3.3.3