-
- Posts: 1
- Joined: Thu Jul 07, 2016 8:35 am
spi.open(0,0) IOError: Errno 2 No such file or directory
I am very new to Python programming, so please be patient.
I am trying to use an MCP3208 chip to input light levels.
I have downloaded a py script (mcp3008_tmp36.py), and run it.
Then I get "spi.open(0,0) IOError: Errno 2 No such file or directory"
The previous lines are:
import spidev
import time
import os
spi = spidev.SpiDev().
spi.open(0,0)
I have updated and upgraded before trying to run the script.
Any help would be appreciated
Thank you.
I am trying to use an MCP3208 chip to input light levels.
I have downloaded a py script (mcp3008_tmp36.py), and run it.
Then I get "spi.open(0,0) IOError: Errno 2 No such file or directory"
The previous lines are:
import spidev
import time
import os
spi = spidev.SpiDev().
spi.open(0,0)
I have updated and upgraded before trying to run the script.
Any help would be appreciated
Thank you.
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Have you enabled SPI in sudo raspi-config?
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Hi there. Just wondering whether we can get this thread restarted because I, too, have the following error:
This error comes after the following code is executed:
Another note - have also ensured using raspi-config that SPI is on, yet nothing.
Would love some help!
Thanks,
B
Code: Select all
IOError: [Errno 2] No such file or directory
Code: Select all
import spidev
import time
spi = spidev.SpiDev()
spi.open(0,0)
while True:
resp = spi.xfer2([0x00])
print resp[0]
time.sleep(1)
Would love some help!
Thanks,
B
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
What is reported by
ls /dev/spi*
ls /dev/spi*
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
It says no such file or directory! Also ran ls | grep "sp" and nothing came up either.joan wrote:What is reported by
ls /dev/spi*
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
SPI is not enabled.
Are you using a recent Raspbian image?
uname -a
cat /etc/os-release
Do you have the line dtparam=spi=on in /boot/config.txt?
Are you using a recent Raspbian image?
uname -a
cat /etc/os-release
Do you have the line dtparam=spi=on in /boot/config.txt?
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
joan wrote:SPI is not enabled.
Are you using a recent Raspbian image?
uname -a
cat /etc/os-release
Do you have the line dtparam=spi=on in /boot/config.txt?
Thanks for getting back to me, Joan! I'm almost certain it is enabled, though. So in raspi-config it is enabled and I'm on Jessie. Futher, I have already ammended the dtparam line you mentioned above to the boot config file.
I don't suppose you know what the next step is?
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
result of uname -a
contents of /etc/os-release
contents of /boot/config,txt
contents of /etc/os-release
contents of /boot/config,txt
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
In an LXterminal run
grep -i 'dtparam' /boot/config.txt
and check that sudo raspi-config has done the right stuff.
Then reboot.
grep -i 'dtparam' /boot/config.txt
and check that sudo raspi-config has done the right stuff.
Then reboot.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Thanks all!
Results:
Dougie, this is the results of your query (of course, also found above if you wish to see in context!)
Results:
Code: Select all
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.34+ #930 Wed Nov 23 15:12:30 GMT 2016 armv6l GNU/Linux
pi@raspberrypi:~ $ vi /etc/os-release/
NOTHING THERE
pi@raspberrypi:~ $ cd /etc/os-release
-bash: cd: /etc/os-release: Not a directory
pi@raspberrypi:~ $ vi /boot/config.txt
# For more options and information see
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi
#Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=w1-gpio,pullup=y
Code: Select all
pi@raspberrypi:~ $ grep -i 'dtparam' /boot/config.txt
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
dtparam=audio=on
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Have you rebooted with that config?
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Thanks for the quick reply - should have said so, but yes I have!DougieLawson wrote:Have you rebooted with that config?
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Can you run sudo fdisk -l /dev/mmcblk0 and post the results.
Is your system run Raspbian because on my Raspbian systems there's a /etc/os-release file which looks like
Is your system run Raspbian because on my Raspbian systems there's a /etc/os-release file which looks like
Code: Select all
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Hi again Dougie,DougieLawson wrote:Can you run sudo fdisk -l /dev/mmcblk0 and post the results.
Is your system run Raspbian because on my Raspbian systems there's a /etc/os-release file which looks likeCode: Select all
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
Yep - running Jessie (lite, I think?) and that file does exist which you are referring to; I must have made a typo copying it in, but the file is there and it looks identical to the one you've provided above.
As for your disk operation command, the results are as follows:
Disk /dev/mmcblk0: 3.7GiB
disklabel: DOS
Device:
/dev/mmcblk0p1 is FAT32 with 63MB size
/dev/mmcblk0p2 is Linux type and 3.6GB
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Have a look at /etc/modprobe.d/raspi-blacklist.conf is spi blacklisted in that file?
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
DougieLawson wrote:Have a look at /etc/modprobe.d/raspi-blacklist.conf is spi blacklisted in that file?
The file is empty, I'm afraid.
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Try sudo rpi-update to get a 4.4.44 kernel and latest bootcode.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Hi Dougie,DougieLawson wrote:Try sudo rpi-update to get a 4.4.44 kernel and latest bootcode.
Done!
Should I now reattempt all of the above? Or perhaps just check the raspi-config is still correct and then check the blacklist?
BC
- DougieLawson
- Posts: 42771
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Your config.txt and cmdline.txt don't change when you run rpi-update. It updates lots of other bits in /boot and /lib/modules.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Thanks for that - updated. I don't suppose there are any more steps before it is better just to reflash a copy of Jessie to the CM?DougieLawson wrote:Your config.txt and cmdline.txt don't change when you run rpi-update. It updates lots of other bits in /boot and /lib/modules.
Thanks, again!
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
I had the same problem and followed all the steps and still got the same error, what allowed me to run the code was:
Without sudo I go the error, with sudo I didn't.
I hope this helps either you or others.
Code: Select all
sudo python program_name
I hope this helps either you or others.
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Try installing spidev and also check ls /dev/spi*... if you are getting something like /dev/spidev1.0 then write 1 instead of the first 0 in spi.open(0,0)...hope this works!
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Edit /boot/config.txt, add the following line, and reboot.
dtoverlay=spi1-3cs
You should then have the following devices.
$ ls /dev/sp*
/dev/spidev0.0 /dev/spidev0.1 /dev/spidev1.0 /dev/spidev1.1 /dev/spidev1.2
dtoverlay=spi1-3cs
You should then have the following devices.
$ ls /dev/sp*
/dev/spidev0.0 /dev/spidev0.1 /dev/spidev1.0 /dev/spidev1.1 /dev/spidev1.2
-
- Posts: 4
- Joined: Sun Aug 16, 2020 1:43 pm
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Hey
This is my first work experience with raspberry pi, i use raspberry pi 3b+
I do not have these spidev files.
What do I need to do now?
Michael
This is my first work experience with raspberry pi, i use raspberry pi 3b+
I do not have these spidev files.
What do I need to do now?
Michael
Re: spi.open(0,0) IOError: Errno 2 No such file or directory
Did you activate SPI?Michael1989 wrote: ↑Sun Aug 16, 2020 1:49 pmHey
This is my first work experience with raspberry pi, i use raspberry pi 3b+
I do not have these spidev files.
What do I need to do now?
Michael