Installing tensorflow on Anaconda - python

I have a linux machine to which i installed Anaconda.
I am following:
https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html
pip instaltion part.
To be more specific:
which python
gives
/home/user/anaconda2/bin/python
After which i entered:
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
And after:
sudo pip install --upgrade $TF_BINARY_URL
However,
while trying:
python -c "import tensorflow"
I get an import error:
ImportError: No module named tensorflow

The 'sudo' makes pip install tensorflow outside the env. Try:
pip install --upgrade $TF_BINARY_URL
Just tested this on Ubuntu 14.04 w/ conda env, was able to reproduce (with sudo) and resolve issue (without sudo).
You can also check the "Using Conda" section of tensorflow.org. They list the below:
# Python 2
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL
# Python 3
(tensorflow)$ pip3 install --ignore-installed --upgrade $TF_BINARY_URL

In anaconda, simply do:
for installation
conda install -c conda-forge tensorflow
for update/upgrade
# -f will force the current installation to upgrade
conda update -f -c conda-forge tensorflow

Related

pip not working while trying to install torch

I'm trying to install torch for ml-agents and when I run the command
pip install torch~=1.7.1 -f https://download.pytorch.org/whl/torch_stable.html
and it answers:
No Python at 'C:\Program Files (x86)\Python38-32\python.exe'
review/reinstall your python installation. The issue is related to Python and Pip, not that library.
First try to fix:
python --version
then
pip --version

Installing a package inside Conda using apt install

I'm trying to install opencv in my Jetson TX2. I would like to install it within my conda environment. I used the following command to do so,
sudo apt-get install python-opencv
It actually installs opencv but outside the conda so I'm not able to import it within conda. How can I have it installed within my conda?.
apt install for system-wide package install
conda install for installing package in conda environment
Make sure you are in a conda environment.
Run a conda command, instead of an apt-get command.
conda install -c conda-forge opencv
You can just install pip in the conda environment and install opencv using pip.
conda install pip
pip install opencv-python

ModuleNotFoundError: No module named 'visdom' when importing visdom

When i'm trying to run the following from python console (pycharm)
import visdom
When I try to run:
module = self._system_import(name, *args, **kwargs)
I get the following error:
ModuleNotFoundError: No module named 'visdom'
I've tried to install it through pip (pip install visdom), pip3 (pip3 install visdom) and conda (all the following commands):
conda install -c conda-forge visdom
conda install -c conda-forge/label/gcc7 visdom
conda install -c conda-forge/label/cf201901 visdom)
None of the above commands produced an error.
I'm using a Mac if it matters.
Always include full traceback firstly in your question. With what i have encountered before, try the following
Upgrade pip,
python -m pip install --upgrade pip
They try,
python -m pip install visdom
I’ve encountered the same issue. I made it by installing visdom0.2.1 while the default version is 0.2.2.
following commands:
pip uninstall visdom
pip install visdom==0.2.1
Try to install with pip:
Install Python server and client from pip
Requires Python 3

Install Gensim in python3

I have two versions of python: python2, python3.
When I install gensim it goes to python2
I install it with the following comand
sudo pip3 install --upgrade gensim
how can I install it in python3?
You can install it in python3 with the following command:
sudo python3 -m pip install --upgrade gensim
I suggest using a virtualenv with only python3 in it. You can create it using
virtualenv -p /usr/bin/python3 myenv
then activate it using source command.
source myenv/bin/activate
now you can install using pip install gensim that will install it to the python3 specific to that virtual environment.

Install Tensorflow in virtual environment python 2.7

Please, how can i install Tensorflow in a virtual environment? I have used these commands but it doesn't work..
sudo -H pip3 install tensorflow --proxy https://XXX.XX.XX.X:3128
sudo -E pip3 install tensorflow --proxy https://XXX.XX.XX.X:3128
sudo -E pip install tensorflow --proxy https://XXX.XX.XX.X:3128
sudo -H pip install tensorflow --proxy https://XXX.XX.XX.X:3128
sudo pip install tensorflow --proxy https://XXX.XX.XX.X:3128
It resulted in:
Downloading/unpacking tensorflow
Cannot fetch index base URL https://pypi.python.org/simple/
These are my python and pip versions:
(venv)root#graphene-62:~/tensorflow# pip -V
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages/pip-8.1.2-py2.7.egg
(python 2.7)
(venv)root#graphene-62:~/tensorflow# python -V
Python 2.7.6
After I tried pip install -U tensorflow, I got the following result:
Cannot uninstall 'six'
Then I tried pip install -U tensorflow --ignore-installed six, and with the tf version check I got:
(venv)root#graphene-62:~/tensorflow# python -c "import tensorflow as tf; print(tf.__version__)"
Illegal instruction (core dumped) (venv)root#graphene-62:~/tensorflow#
Is there another way to download and install Tensorflow?
Please make sure that your pip version is up to date with:
pip install -U pip
Then, as per the comments and edited question, execute:
pip install -U tensorflow==1.5.0 --ignore-installed six
This will ignore the six related error and the slightly downgraded tensorflow package will install and be useable without the Illegal Instruction error.
To check if the installation was successfull, execute:
python -c "import tensorflow as tf; print(tf.__version__)"
Recently, pip install tensorflow with python 2.7 might cause the error message:
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
You can instead install TensorFlow with:
pip install -U https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.14.0-cp27-none-linux_x86_64.whl
You can replace the URL of the wheel with some other URLs from https://www.tensorflow.org/install/pip
Same issue with tensorflow-gpu.

Categories