TypeError: expected str, bytes or os.PathLike object, not None Type

I am trying to run this code in Pycharm, but I'm getting below error:

TypeError: expected str, bytes or os.PathLike object, not NoneType 

This is for windows 10, running on Pycharm, python 3.7

import os import time file_path = os.path.join(os.getenv("HOME"), "birth_day_lookup.txt") def check_birthday(): lookup_file = open(file_path, 'r') today = time.strftime('%d-%B') flag = 0 for entry in lookup_file: if today in entry: line = entry.split(' ') flag = 1 os.system('notify-send "Today is '+line[1]+' '+line[2]+'\'s Birthday"') if flag == 0: os.system('notify-send "No birthday for today is listed"') check_birthday() 
6

4 Answers

Apparently os.getenv("HOME") would return a Nonetype value if the environment variable doesn't exist. Try os.getenv('HOME', "not found") to be sure. --gives output as "not found" if the env is not available. Rather, you can use os.getcwd() if the .py file exits in the same directory as birth_day_lookup.txt. Hope this helps.

0

Delete .condarc file in location C:\Users\UserName\

0

Python expects that there will be, for example, a string (str) or a PathLike object, which you can read about in the official documentation https://docs.python.org/3/library/os.path.html#module-os.path

Remove pycache folders and try one more again

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobG9waW2Dc3yOrbCpnZWnv7C%2BjJ6vqZ2TqbKledKtqWaaqamytHnOq2Soq12lrrW0y6KinmWfl7emr9NmpaisXaO8r7GMrbCpnQ%3D%3D