Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about shapefile
#1
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
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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'
Reply
#4
https://stackoverflow.com/a/514395/4046632

I would guess ghost shapefile.pyc from the previous run makes a problem
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating a Point from coordinate fields in shapefile stixmagiggins 0 1,600 Aug-28-2019, 06:33 AM
Last Post: stixmagiggins

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020