filenotfounderror no such file or directory pygame что делать
pygame.error: /etc/timidity.cfg: No such file or directory #343
Comments
japrogramer commented Jul 20, 2017 •
Hello im getting an error when using timidity++ with pygame
pygame.error: /etc/timidity.cfg: No such file or directory
The text was updated successfully, but these errors were encountered:
japrogramer commented Jul 20, 2017
takluyver commented Jul 22, 2017
Is there a traceback associated with that error?
japrogramer commented Jul 24, 2017 •
I was trying to play a midi file, cant remeber exactly how. after i made the link between the files the error went away but no sound played. i was running the code from jupyter notebook.
neither the host nor client played music.
pygame.error: /etc/timidity.cfg: No such file or directory
takluyver commented Jul 25, 2017
When you get an error from Python code, it usually displays a ‘traceback’, which shows what functions were running when the problem happened. It might be quite long, depending on the code involved. It will be a series of chunks like this:
The error message is usually displayed at the bottom of this.
If you get a traceback, it’s really important info for debugging, so it’s a good thing to include in bug reports. If there isn’t one for some reason, that’s OK, but hopefully that’s unusual. 🙂
adicarlo commented Sep 21, 2017
Its not clear to me this is really a pygame bug. I can’t see anywhere in the sources where the path to the config file is hardcoded.
takluyver commented Sep 22, 2017
cid0rz commented Feb 4, 2018
Hello all, I am also using jupyter to work with music21 musicological analysis tool. I tried to play before installing pygame and it complained it needed pygame. So I installed. I’m in pytjon 3.6 on Xenial and i try this example taken from here:
FileNotFoundError: [Errno 2] No such file or directory: Python
FileNotFoundError: [Errno 2] No such file or directory: выходит после того как я пытаюсь открыть файл.
Тут я запускаю скрипт с меин файла скрин https://prnt.sc/vm8psi
Дальше этот меин файл запускает скрипт но сначала записывает данные в файл.
После чего в скрипте происходит следущее
Скрипт находитса в данной директории https://prnt.sc/vm8s9a
А файл в который я записываю данные находитса в https://prnt.sc/vm8sya
Эту функцию я вызываю в отдельном потоке.
1 ответ 1
Файл не находится, потому, что не там ищете. Проверьте перед вызовом open что вернет os.getcwd() в обоих случаях. Очевидно, что в программе неправильные предположения о текущем рабочем каталоге. Либо используйте полный путь либо по другому синхронизируйте место записи и чтения.
Всё ещё ищете ответ? Посмотрите другие вопросы с метками python или задайте свой вопрос.
Похожие
Подписаться на ленту
Для подписки на ленту скопируйте и вставьте эту ссылку в вашу программу для чтения RSS.
дизайн сайта / логотип © 2021 Stack Exchange Inc; материалы пользователей предоставляются на условиях лицензии cc by-sa. rev 2021.11.9.40693
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
Python FileNotFoundError: [Errno 2] No such file or directory:
I am trying to open all the ‘*.json’ files in a directory and get some data out of them
This is the Error i get :
3 Answers 3
You are running the script in different path. Adding the absolute path of the filename will do the trick.
replace line with open(filename,’r’) as f: with with open(os.path.abspath(filename),’r’) as f:
If you want Python to find within the given path, you should write somthin like :
Not the answer you’re looking for? Browse other questions tagged python or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.11.9.40693
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Ошибка в программном коде, на python
Ошибка в коде на python! Сайт с которого я брал код! https://tokmakov.msk.ru/blog/item/60
Я понял что ошибка в этом! file = open(‘C:\\example\\tinko.txt’, mode = ‘w’, encoding = ‘utf-8’) у меня нету такого файла на ПК! Что делать?
что выдаёт;
Traceback (most recent call last):
File «C:/Users/one-h/PycharmProjects/pythonProject/rwrf.py», line 9, in
file = open(‘C:\\example\\tinko.txt’, mode = ‘w’, encoding = ‘utf-8’)
FileNotFoundError: [Errno 2] No such file or directory: ‘C:\\example\\tinko.txt’
и ещё
pydev debugger: process 3016 is connecting
Connected to pydev debugger (build 202.6397.98)
Traceback (most recent call last):
File «C:\Program Files\JetBrains\PyCharm 2020.2\plugins\python\helpers\pydev\pydevd.py», line 1448, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File «C:\Program Files\JetBrains\PyCharm 2020.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py», line 18, in execfile
exec(compile(contents+»\n», file, ‘exec’), glob, loc)
File «C:/Users/one-h/PycharmProjects/pythonProject/rwrf.py», line 9, in
file = open(‘C:\\example\\tinko.txt’, mode = ‘w’, encoding = ‘utf-8’)
FileNotFoundError: [Errno 2] No such file or directory: ‘C:\\example\\tinko.txt’
Как вы беретесь программировать, не зная ЭЛЕМЕНТАРНОГО?!
при открытии на запись, файл создаётся автоматически (или перезаписывается). Эта ошибка означает, что не существуют эти папки.
Перед открытием файлов лучше проверять и создавать нужные пути:
Python. Почему FileNotFoundError: [Errno 2] No such file or directory: ‘screenshot.PNG’?
То есть файл существует. Буду признателен, если подскажете, что не правильно в строке 101.
Скрипт запускается по этому пути
Папка INBOX находится в /home/m.kos
Все равно не получается ((
Я даже не пойму как увидеть по какому пути скрипт ищет папку attachments.
Dr. Bacon, но я пробовал разместить screenshot.PNG в папку send_tickets (send_tickets/screenshot.PNG) и все-равно ругается, что нет файла.
Значит я уже там, в INBOX по абсолютному пути. Тогда какая связь с /home/m.kostromin/send_tickets, где находится main.py?
Dr. Bacon, я извиняюсь за свою несообразительность но
как я в переменной file укажу полный путь, если у каждого полученного нового письма уникальный путь?
Сейчас screenshot.PNG находится по этому пути
В этом блоке я перехожу в /home/m.kostromin/send_tickets/INBOX, там получаю список папок, затем перехожу в одну из папок и если там есть text_plain.txt или text_html.html, то отправляю. Но если в папке вдруг есть папка attachments, то я просматриваю её и её содержимое отправляю в телеграм. Ведь скрипт корректно находит text_plain.txt или text_html.html и так же корректно их отправляет, но attachments он не видит.
Я сейчас остановил выполнение скрипта на шаге отправки файлов в телеграм и как видно на скриншоте есть файл text_html.html. Если я продолжу выполнение скрипта, то файл text_html.html корректно уйдет в телеграм, но attachments скрипт не найдет.