ImportError: cannot import name 'SummaryWriter' from 'tensorboard'

I cannot run my code with tensorboard because of this error. This is my env:

python==3.10
pytorch==1.11.0
torch==1.11.0
torchvision==0.12.0
tensorboard==1.15.0
tensorboardX==2.5.1
protobf==3.8.0

I’ve tried importing as rom torch.utils.tensorboard import SummaryWriter
and also I tried this: from tensorboardX import SummaryWriter. None has worked. The latter lead to the error that there is no package called tensorboardX while it was already installed. I am out of ideas. I tried everything I could find on the internet. Any help would be immensely appreciated.

maybe try to update tensorboard

Just tired:

pip install tensorboard -U

now I have:

tensorboard==2.10.0
protobuf==3.19.5

I still get the same error.


Created new virtual env and tried installing the same packages as you and its working on my side.
use conda to install everything.

conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge \\
conda install -c conda-forge tensorboardx \\
conda install -c anaconda protobuf


Here, is my pip freeze:

asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1660605382950/work
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work
brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1648854167867/work
certifi==2022.9.14
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1656782834004/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1661170624537/work
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1657173997940/work
debugpy @ file:///home/conda/feedstock_root/build_artifacts/debugpy_1660619028387/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work
entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1661768596365/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1642433548627/work
ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1663104864651/work
ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1662481517711/work
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1659959867326/work
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1661522530937/work
jupyter_core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1658332342865/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1660814786464/work
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1648959695634/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1662888869821/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1660385859913/work
prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1662384672173/work
protobuf==3.20.1
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1662356158604/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1660666458521/work
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1663314975974/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1661872987712/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1661624565828/work
tensorboardX @ file:///home/conda/feedstock_root/build_artifacts/tensorboardx_1654638215170/work
torch==1.12.1
torchaudio==0.12.1
torchvision==0.13.1
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1656937830246/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1663005918942/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1656706066251/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1658789158161/work
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work
1 Like

the problem is that I couldn’t download the packages with conda. I updated my conda, now it is conda==4.14.0 but I get an error trying ```

pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge

This is the error:


 CondaVerificationError: The package for pytorch located at /visinf/home/shamidi/anaconda3/pkgs/pytorch-1.12.1-py3.9_cuda11.6_cudnn8.3.2_0
 appears to be corrupted. The path 'lib/python3.9/site-packages/torchgen/static_runtime/config.py'
 specified in the package manifest cannot be found.

remove the corrupted package and reinstall it similar to what they have done in here .

p.s. If your installation of pytorch is taking too much time and if you have a VPN, then switch location to anywhere in the USA to get better speed when downloading!

1 Like