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

papoo13: <p>I cannot run my code with tensorboard because of this error. This is my env:</p>
<p>python==3.10<br>
pytorch==1.11.0<br>
torch==1.11.0<br>
torchvision==0.12.0<br>
tensorboard==1.15.0<br>
tensorboardX==2.5.1<br>
protobf==3.8.0</p>
<p>I’ve tried importing as rom torch.utils.tensorboard import SummaryWriter<br>
and also I tried this: <code>from tensorboardX import SummaryWriter</code>. 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.</p>

wi-sh: <p>maybe try to update tensorboard</p>

papoo13: <p>Just tired:</p>
<blockquote>
<p>pip install tensorboard -U</p>
</blockquote>
<p>now I have:</p>
<blockquote>
<p>tensorboard==2.10.0<br>
protobuf==3.19.5</p>
</blockquote>
<p>I still get the same error.</p>

wi-sh: <aside class="quote no-group" data-username="papoo13" data-post="1" data-topic="161537">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/p/f19dbf/48.png" class="avatar"> papoo13:</div>
<blockquote>
<p><code>from tensorboardX import SummaryWriter</code></p>
</blockquote>
</aside>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/0/d0a1dba2033614672c2a1c523980836a4a5f128d.png" data-download-href="https://discuss.pytorch.org/uploads/default/d0a1dba2033614672c2a1c523980836a4a5f128d" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0a1dba2033614672c2a1c523980836a4a5f128d_2_690x120.png" alt="image" data-base62-sha1="tLE5L4R0eMPaGO8p8VgiclwWxel" width="690" height="120" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0a1dba2033614672c2a1c523980836a4a5f128d_2_690x120.png, https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0a1dba2033614672c2a1c523980836a4a5f128d_2_1035x180.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0a1dba2033614672c2a1c523980836a4a5f128d_2_1380x240.png 2x" data-dominant-color="24282E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1427×250 20.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
Created new virtual env and tried installing the same packages as you and its working on my side.<br>
use <code>conda</code> to install everything.</p>
<pre data-code-wrap="bash"><code class="lang-bash">conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge \\
conda install -c conda-forge tensorboardx \\
conda install -c anaconda protobuf


</code></pre>
<p>Here, is my <code>pip freeze</code>:</p>
<pre><code class="lang-auto">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
</code></pre>

papoo13: <aside class="quote no-group" data-username="wi-sh" data-post="4" data-topic="161537">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/wi-sh/48/53085_2.png" class="avatar"> wi-sh:</div>
<blockquote>
<p><code>pytorch torchvision torchaudio cudatoolkit=11.6 </code></p>
</blockquote>
</aside>
<p>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 ```</p>
<blockquote>
<p>pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge</p>
</blockquote>
<p>This is the error:</p>
<pre><code class="lang-auto">
 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.
</code></pre>

wi-sh: <p>remove the corrupted package and reinstall it  similar to what they have done in <a href="https://datascience.stackexchange.com/questions/41732/conda-verification-failed" rel="noopener nofollow ugc">here</a> .</p>
<p>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!</p>