T
T
Ternick2018-08-19 17:49:18
Python
Ternick, 2018-08-19 17:49:18

What does it mean: TypeError: expected str, bytes or os.PathLike object, not NoneType?

Error log:

Traceback (most recent call last):
  File "C:\Users\Ternick\Desktop\1\main.py", line 203, in <module>
    main()
  File "C:\Users\Ternick\Desktop\1\main.py", line 174, in main
    sendImage(chat_id, a)
  File "C:\Users\Ternick\Desktop\1\main.py", line 141, in sendImage
    with open(path_to_mg, 'rb') as path_to_mg_god:
TypeError: expected str, bytes or os.PathLike object, not NoneType
[Finished in 350.7s]

Description of what is wrong:
Well, the essence of the code is that it loads a module that gives it a picture, it sends this picture to me via Telegram. And errors get out at the moment of opening of a picture for the subsequent sending to it! I have already tried a lot of different options and sleep () and now I checked whether this application is open or not. Since it's all in different folders, I still don't understand why it throws a photo to me in the folder with the main application, although it should save it to the folder with the downloaded file!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Simon Osipov, 2018-08-20
@Ternick

The error says that it path_to_mgstores in itself None, that is, there is nothing there.
And Python expects that there will be, for example, a string (str) or a PathLike object, which you can read about in the official documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question