When you work in PyCharm you create a “Project” - a folder where all your code and data files are located. To use a TensorBoard you should create a subfolder in this project folder and call it, for example, “logs”.
To define a relative path to this “logs” subfolder, which is one level below the folder with the code file, you use . as an identifier of the current working directory like this:
log_dir = "./logs/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
When you run the code, you can manually check that new content is automatically loaded in the “logs” folder.
To activate TensorBoard you launch the terminal from the bottom of PyCharm window. There you should be able to see the absolute path to your “Project” folder starting from the C: drive.
You enter the command with a relative path: tensorboard --logdir ./logs/
Together with the absolute path to the “Project” folder this relative path should be a correct path to the “logs”. Errors appear if there is any inconsistency in this path. Like if your code file is located not in the main project folder but is some other place. Then you should carefully define the relative path to the logs.
You can also consult the documentation: Get started with TensorBoard | TensorFlow