lthiery / SPI-Py

Hardware SPI as a C Extension for Python
289 stars 150 forks source link

SPi has no attribute openSpi #26

Closed MilesWK closed 7 months ago

MilesWK commented 1 year ago

I am have a lot of problems with it on my Raspberry Pi. I am trying to use the MFRC552 module and it gives me the error

Spi has no attribute 'openSpi'. I would really appreciate it if you fixed it, or you showed me how to fix it. Thanks!

KevinVan9 commented 1 year ago

~~If you look at the output during the install it says that setup.py install is deprecated. To work around this: pip3 install setuptools==58.2.9~~

Refer to my next comment

MilesWK commented 11 months ago

@KevinVan9 It says that there is no matching distributions on that module.

KevinVan9 commented 10 months ago

@KevinVan9 It says that there is no matching distributions on that module.

I realised that I have mixed up this project with mfrc522. If you install using python 2, it should work (you need python-dev installed). Here is the install log:

root@Pi:~/SPI-Py# sudo python setup.py install
running install
running build
running build_ext
building 'spi' extension
arm-linux-gnueabihf-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-4UUT22/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c spi.c -o build/temp.linux-armv6l-2.7/spi.o
creating build/lib.linux-armv6l-2.7
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-4UUT22/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -ffile-prefix-map=/build/python2.7-4UUT22/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC build/temp.linux-armv6l-2.7/spi.o -o build/lib.linux-armv6l-2.7/spi.so
running install_lib
copying build/lib.linux-armv6l-2.7/spi.so -> /usr/local/lib/python2.7/dist-packages
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/SPI_Py-1.0.egg-info

Here is the failed python 3 install:

root@Pi:~/SPI-Py# sudo python3 setup.py install
running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python3.9/dist-packages/SPI_Py-1.0.egg-info
Writing /usr/local/lib/python3.9/dist-packages/SPI_Py-1.0.egg-info

Funnily enough, after building using 2, importing in 3 works

MilesWK commented 10 months ago

Ahh. Let me try that!

MilesWK commented 7 months ago

Okay so I found out that I had the file in the wrong area so the imports were not working... once I ran in the console it worked.

I am closing this issue: This comment me fix my issue!