Python Forum
Question about shapefile - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Question about shapefile (/thread-11771.html)



Question about shapefile - oz1988 - Jul-25-2018

Hi,

I'm using anaconda version 1.8.7
Spyder 3.2.8
Python 3.6

This is my code:

import shapefile

ctr = shapefile.Reader('/Users/oze/SHP/')
I get the following error:
AttributeError: module 'shapefile' has no attribute 'Reader'

Anyone have an idea ?

TNX

Oz


RE: Question about shapefile - buran - Jul-25-2018

Please, ALWAYS post the entire traceback that you get. We need to see the whole thing - it has important information. Do not just give us the last line.
Take a time to read What to include in a post

In this case, I put my money on your filename to be shapefile.py. Is that the case? This is something we would see in the traceback, if it was the entire one. Rename your file name to be something different from shapefile.py


RE: Question about shapefile - oz1988 - Jul-25-2018

You're right. It was the name of the file. But even after I changed the problem exists.

The code:
import shapefile
 
ctr = shapefile.Reader('/Users/oze/SHP/')
And...

Error:
runfile('C:/Users/oze/.spyder/test5.py', wdir='C:/Users/oze/.spyder') Traceback (most recent call last): File "<ipython-input-17-723d523bc0ed>", line 1, in <module> runfile('C:/Users/oze/.spyder/test5.py', wdir='C:/Users/oze/.spyder') File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/Users/oze/.spyder/test5.py", line 1, in <module> import shapefile ImportError: bad magic number in 'shapefile': b'\x03\xf3\r\n'



RE: Question about shapefile - buran - Jul-25-2018

https://stackoverflow.com/a/514395/4046632

I would guess ghost shapefile.pyc from the previous run makes a problem