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.
Related
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 am trying to install Pytorch via pip on ubuntu 18.04.I have python 3.6 and my laptop is HP-Pavilion notebook 15
The installation seems to be right because i get the message:
Installing collected packages: torch, torchvision Successfully
installed torch-1.3.1+cpu torchvision-0.4.2+cpu
i run the verification code and it is ok
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
However, when i close the terminal or reboot and try to run he same code i get the error:
Traceback (most recent call last):
File "torch.py", line 2, in
import torch
AttributeError: module 'torch' has no attribute 'rand'
How are you executing the python script? Which python are you using? Maybe you installed the package in a different python version?
Try to set alias to the python you want to use:
alias python=/usr/local/bin/python3.6
Then pip install the package with that python alias you will always be using.
python pip install <package name>
Python now will install the package in the python files with the alias python - heading to files: /usr/local/bin/python3.6
Let me know if the error still occurs!
Install pytorch using pip through the below command:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
for any reference go through the official website of pytorch.
Change your file .py to another name, you named torch.py when you import torch it will call ur torch.py
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
I tried to install statsmodels in python. After installation, I checked with pip freeze. The package can be seen in the list.
When I am trying:
from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
I am getting error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name ExponentialSmoothing
I have tried the following link also :
link
As of today (10 May 2018), the problem is solved by simply installing version 0.9.0 rather than the default 0.8.0:
pip install statsmodels==0.9.0rc1
I met the same situation, and the install process recommended in Nish's url didn't work for me. Here's how did I solve the problem (I'm using Mac OS).
Remove statsmodels library first, if you have installed: pip uninstall statsmodels
In your terminal, type git init, to initiate git
Then type git clone git://github.com/statsmodels/statsmodels.git
Change the directory to statsmodels using “cd statsmodels”
Next type python setup.py install
python setup.py build_ext --inplace
Now type python in your terminal and then type from statsmodels.tsa.api import ExponentialSmoothing, to see whether it can import successfully
If using conda, this will make statsmodel 0.9.0
conda update statsmodels
It is the wrong import,
Try
from statsmodels.tsa.holtwinters import ExponentialSmoothing, SimpleExpSmoothing, Holt
You can follow the steps mentioned below:
Step 1: Remove statsmodel using pip uninstall statsmodel
Step 2: Install git from here: https://git-scm.com/downloads
Step 3: Follow steps mentioned under "Installing library(statsmodels)" from link mentioned below:
https://www.analyticsvidhya.com/blog/2018/02/time-series-forecasting-methods/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+AnalyticsVidhya+%28Analytics+Vidhya%29