'tensorboard: error: invalid choice: 'code' (choose from 'serve', 'dev') - while trying to run tensorboard

When I try to run tensorboard using the command

(tensorflow) C:\Users\ANVAY>tensorboard --logdir=D:\Documents\Vs code python\my_log_dir

in the anaconda prompt after I have activated tensorflow, I get this error:

(tensorflow) C:\Users\ANVAY>tensorboard --logdir=D:\Documents\Vs code python\my_log_dir
2020-08-11 23:02:45.376116: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
usage: tensorboard [-h] [--helpfull] [--logdir PATH] [--logdir_spec PATH_SPEC]
                   [--host ADDR] [--bind_all] [--port PORT]
                   [--purge_orphaned_data BOOL] [--db URI] [--db_import]
                   [--inspect] [--version_tb] [--tag TAG] [--event_file PATH]
                   [--path_prefix PATH] [--window_title TEXT]
                   [--max_reload_threads COUNT] [--reload_interval SECONDS]
                   [--reload_task TYPE] [--reload_multifile BOOL]
                   [--reload_multifile_inactive_secs SECONDS]
                   [--generic_data TYPE]
                   [--samples_per_plugin SAMPLES_PER_PLUGIN]
                   [--debugger_data_server_grpc_port PORT]
                   [--debugger_port PORT]
                   {serve,dev} ...
tensorboard: error: invalid choice: 'code' (choose from 'serve', 'dev')

Package versions:
Tensor Flow Version: 2.1.0
Keras Version: 2.2.4-tf
Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]

I have also tried using the following commands but get the same error

tensorboard --logdir D:\Documents\Vs code python\my_log_dir  
python -m tensorboard.main --logdir=D:\Documents\Vs code python\my_log_dir

One thing that I noticed while trying to make this work is, in the file tensorboard-script.py under the directory C:\Users\ANVAY\miniconda3\envs\tensorflow\Scripts I get this warning [ unresolved import 'tensorboard.main'Python(unresolved-import) ]
and also in the file main.py under the directoryC:\Users\ANVAY\miniconda3\envs\tensorflow\Lib\site-packages\tensorboard, I get a similar warning

I have no problems with training models and other stuff.



Solution 1:[1]

From Comments

The problem is the spaces in the path, try with --logdir="D:\Documents\Vs code python\my_log_dir"(paraphrased from Dr. Snoopy)

Solution 2:[2]

I got this error when I entered the argument as --log-dir instead of --logdir.

Solution 3:[3]

For me is running but passing the tensorflow command as bash argument.

I report here the Kubernetes Pod spec that can be used to extract the command:

  containers:
  - args:
    # - '--host 0.0.0.0'
    # - '--logdir=/tensorboard_logs/'
    - '-c'
    - '/usr/local/bin/tensorboard --host 0.0.0.0 --logdir=/tensorboard_logs/'
    command:
    # - /usr/local/bin/tensorboard
    - bash

The commented lines are the original ones not working.

Solution 4:[4]

%tensorboard --logdir="my_log_dir" --port=8892 Try this in jupyter notebook

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 craq
Solution 3 Gian Luigi Romita
Solution 4 Kishan Kumar