I am changing my working directory to make sure images are loaded from the right place.
import os
cwd = os.getwd() ##works fine
newwd = os.chdir("C:\\Users\\Me\\Python\\Images") ##gives NoneType object
I never had problems with that before. Now as opposed to saving the variable as a string (i.e. the path I specified), it saves it as a NoneType of size = 1, so it is essentially empty. I tried with \, //, /, \, single or double quotations. I copied even the line of code I used before, from a previous python file, and it still does the same.
As described in the docs here, os.chdir(path)
changes the current working directory to the path specified. It doesn't return anything, hence why you get newwd = None
. You can just run
os.chdir("C:\\Users\\Me\\Python\\Images")
to change the working directory. Then os.getcwd()
will return "C:\\Users\\Me\\Python\\Images"
.