I"m going through this tutorial to set up pytorch (v1.3.0 through conda) with tensorboard https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html#
but on the step
from torch.utils.tensorboard import SummaryWriter
# default `log_dir` is "runs" - we'll be more specific here
writer = SummaryWriter('runs/fashion_mnist_experiment_1')
I keep getting the error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
C:\ProgramData\Anaconda3\envs\fastai_v1\lib\site-packages\torch\utils\tensorboard\__init__.py in
1 try:
----> 2 from tensorboard.summary.writer.record_writer import RecordWriter # noqa F401
3 except ImportError:
ModuleNotFoundError: No module named 'tensorboard.summary'; 'tensorboard' is not a package
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
c:\Users\matt\Documents\code\playground\tensorboard.py in
----> 1 from torch.utils.tensorboard import SummaryWriter
2
3 # default `log_dir` is "runs" - we'll be more specific here
4 writer = SummaryWriter('runs/fashion_mnist_experiment_1')
C:\ProgramData\Anaconda3\envs\fastai_v1\lib\site-packages\torch\utils\tensorboard\__init__.py in
2 from tensorboard.summary.writer.record_writer import RecordWriter # noqa F401
3 except ImportError:
----> 4 raise ImportError('TensorBoard logging requires TensorBoard with Python summary writer installed. '
5 'This should be available in 1.14 or above.')
6 from .writer import FileWriter, SummaryWriter # noqa F401
ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.
Does anyone have any suggestions?
The error log says, among other things,
ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.
So, when it tries to import TensorBoard, it's unable to do so because it's missing it in the search path. You can install the latest version (without specifying any version number), as in:
$ conda install -c conda-forge tensorboard
Apart from that, you might also need to install protobuf:
$ conda install -c conda-forge protobuf
These installations should fix the ImportErrors.
I came across the same error, I solved by taking the following steps:
Removed all installation of Tensorflow or Tensorboard from the conda environment.
Then by activating the same conda environment, type "pip install -U tb-nightly"
Then type, "pip install -U future"
done
I think it's a version problem.
just run this:
pip install tensorboard==1.14.0
(not pip install tensorboard==1.14)
or just install the tensoflow 1.14.0, which contains the tensorboard 1.14.0:
pip install tensorflow==1.14.0
This version of tensorflow worked for me in pytorch 1.2.
I've done:
conda install -y tensorboard
before with no problems, so Im not sure why that wouldn't work. It's the simplest.
I met the same error, and my conda also didn't work that time, so I chose to use tensorboardX, it is almost absolutely the same as tensorboard(also its operations).
Just install it with pip install tensorboardX
And you can import it with from tensorboardX import SummaryWriter
Related
I am trying to install stable-baselines and run the first two lines from Getting Started section of the online manual but no option is working. I started with
pip install stable-baselines
Now when I run:
import gym
from stable_baselines.common.policies import MlpPolicy
I get
No module named 'tensorflow.contrib'
This apparently is because tensorflow version 2 doesn't have tensorflow.contrib. But version 2 was released in Sept 2019. Do I really have to use only tensorflow version 1?
What is the right way to install stable-baselines and run that simple example?
I tried
pip install stable-baselines3
in a virtual environment. This gives a different error:
In [2]: from stable_baselines.common.policies import MlpPolicy
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [2], in <module>
----> 1 from stable_baselines.common.policies import MlpPolicy
ModuleNotFoundError: No module named 'stable_baselines'
In [3]: from stable_baselines3.common.policies import MlpPolicy
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [3], in <module>
----> 1 from stable_baselines3.common.policies import MlpPolicy
ImportError: cannot import name 'MlpPolicy' from 'stable_baselines3.common.policies' (/home/raph/RL/stable-baselines/venv/lib/python3.8/site-packages/stable_baselines3/common/policies.py)
To quote the github readme:
Note: Stable-Baselines supports Tensorflow versions from 1.8.0 to 1.14.0. Support for Tensorflow 2 API is planned.
The same github readme also recommends to use stable-baselines3, as stable-baselines is currently only being maintained and its functionality is not extended. Thus, I would not expect the TF1 -> TF2 update any time soon.
If you can not install this version of tensorflow, I suggest to use stable-baselines3 and follow the examples. The code you posted above is not consistent with the stable-baselines3 docs, which import the MlpPolicy as
from stable_baselines3.sac.policies import MlpPolicy
According to the stable-baselines documentation you can only use Tensorflow version 1.8.0 to version 1.15.0.
If you want to run Tensorflow 1, and you want to use pip as your package manager, you'll need to install python version 3.7 or lower. I did the following in my ubuntu terminal
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7
sudo apt install virtualenv
virtualenv --python=/usr/bin/python3.7 <env-name>
source <env-name>/bin/activate
pip install tensorflow==1.15.0
...
Alternatively, you could try using this guide, which gives instructions as to how to migrate something to Tensorflow version 2.
I try to install Transformer from pyproj and get the message "cannot import name".
I installed pyproy using Anaconda Navigator. There it tells me I have version 1.9.6. (newest update). I found a thread about same issue but it didn't help me (cannot import name Transformer from pyproj).
I checked pyproj-Documentation and installed via terminal conda install -c conda-forge proj-datumgrid-europe proj-datumgrid-north-america proj-datumgrid-oceania proj-datumgrid-world.
Not sure if that's the right thing to do. I'm a noob .-. help is appreciated.
ImportError Traceback (most recent call last)
/var/folders/jy/1f2tlvb965g30zhw9q3cvdw07r5rb_/T/ipykernel_49825/1776791710.py in <module>
4 from shapely.geometry import Point, LineString
5 import pyproj as pi
----> 6 from pyproj import Transformer
ImportError: cannot import name 'Transformer' from 'pyproj' (/Users/vob/opt/anaconda3/envs/geopandas/lib/python3.8/site-packages/pyproj/__init__.py)
The latest version of pyproj is 3.3 at the moment. To update, recommend looking at pyproj installation instructions: https://pyproj4.github.io/pyproj/stable/installation.html
Here is a snippet:
conda config --prepend channels conda-forge
conda config --set channel_priority strict
conda create -n pyproj_env pyproj
conda activate pyproj_env
I am following a Real time object detection on https://automaticaddison.com/real-time-object-recognition-using-a-webcam-and-deep-learning/#top and I have hit a road block I followed all the instructions and checked for any errors but still got this error
(I am using windows)
Traceback (most recent call last): File "object_detection_test.py",
line 15, in <module>
from utils import label_map_util File "C:\Users\1rock\Documents\TensorFlow\models\research\object_detection\utils\label_map_util.py",
line 27, in <module>
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
I used pip install --ignore-installed --upgrade tensorflow==1.9 just what the link above said and whilst running I got these packages and their versions and an error hope it would be relevant to the question
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ipywidgets 7.6.0 requires jupyterlab-widgets>=1.0.0, which is not installed.
Successfully installed absl-py-0.11.0 astor-0.8.1 gast-0.4.0 grpcio-1.34.0 importlib-metadata-3.3.0 markdown-3.3.3 numpy-1.19.4 protobuf-3.14.0 setuptools-51.0.0.post20201207 six-1.15.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 typing-extensions-3.7.4.3 werkzeug-1.0.1 wheel-0.36.2 zipp-3.4.0
I used pip install --ignore-installed --upgrade tensorflow==1.9
line 27, in
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
TF 1.9 and earlier do not have compat module. To use it you need TF 1.10+. Its better to use conda install everywhere possible with conda virtual enviroment.
Also since you are using tensorflow models make sure you has corresponding version of repository, for example latest TF1.x version located here
I want to check torch version in my device using Jupyter Notebook.
I'm used this
import torch
print(torch.__version__)
but it didn't work and Jupyter notebook raised an error as below
AttributeError Traceback (most recent call last)
<ipython-input-8-beb55f24d5ec> in <module>
1 import torch
----> 2 print(torch.__version__)
AttributeError: module 'torch' has no attribute '__version__'
Is there any command to check torch version using Jupyter notebook?
Try this. Open your terminal
python3 -c "import torch; print(torch.__version__)"
I have tried to install new Pytorch version. But, it didn't work and then I deleted the Pytorch files manually suggested on my command line. Finally, I installed new Pytorch version using conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch and everything works fine.
This code works well after that.
import torch
print(torch.__version__)
You can check list all installed python modules with version tag via pip.
To ensure running the proper pip version, just execute it via the python interpreter:
# python symlink
python -m pip freeze
# python3
python3 -m pip freeze
You can grep for the module of question (used numpy as an example)
python -m pip freeze | grep numpy
numpy==1.19.4
If in the terminal, use pip.
user#debian:~/..$ pip3 show torch
Name: torch
Version: 1.11.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages#pytorch.org
License: BSD-3
Location: /home/user/.local/lib/python3.7/site-packages
Requires: typing-extensions
Required-by: torchaudio, torchvision
I have tried installing fasttext through conda using two channels:
conda install -c conda-forge fasttext
and
conda install -c conda-forge/label/cf201901 fasttext
as per (https://anaconda.org/conda-forge/fasttext).
I am using the following command to import: import fasttext
However, the import fails with the error:
ModuleNotFoundError Traceback (most recent call
last) in
----> 1 import fasttext
ModuleNotFoundError: No module named 'fasttext'
However, tried to import it in an older fashion import fastText, which failed.
Have tried it on python and python3, both of which fail.
I want to avoid installing it using pip and manage the packages using conda.
conda list shows that fasttext being installed. The output of which is shown below:
fasttext 0.2.0 hfc679d8_1 conda-forge/label/cf201901
The output of python -c 'import sys; print(sys.path) is as below:
['', '/<dir>/<dir>/anaconda3/lib/python37.zip', '/<dir>/<dir>/anaconda3/lib/python3.7', '/<dir>/<dir>/anaconda3/lib/python3.7/lib-dynload', '/<dir>/<dir>/anaconda3/lib/python3.7/site-packages']
I used fastText in this way:
!git clone https://github.com/facebookresearch/fastText.git
!cd fastText
!pip install fastText
import fasttext.util
fasttext.util.download_model('en', if_exists='ignore') # English
model = fasttext.load_model('cc.en.300.bin')
Note 1: Pay attention to uppercase letters.
Note 2: Here is the list of supported languages.