Have two different TensorFlow's, how to uninstall both completely? - python

I have TensorFlow 0.12 that I built from source for GPU support a few months. There was some problems with it that I solved right now but in the downtime I'd installed TensorFlow 1.0.1 using pip install tensorflow-gpu. I want to know how exactly to uninstall both and start over by installing TF 1.0. What else do I need to do other than deleting /home/username/anaconda2/lib/python2.7/site-packages/tensorflow/? This is the output when I use the following commands:
$ pip show tensorflow
Name: tensorflow
Version: 0.12.0rc1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /home/username/anaconda2/lib/python2.7/site-packages
Requires: mock, numpy, protobuf, wheel, six
$ pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.0.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /home/username/anaconda2/lib/python2.7/site-packages
Requires: mock, numpy, protobuf, wheel, six
On navigating to the tensorflow-gpu folder in site-packages I found some few files, mostly text
$ cd anaconda2/lib/python2.7/site-packages/tensorflow_gpu-1.0.1.dist-info/
$ ls
DESCRIPTION.rst entry_points.txt METADATA metadata.json RECORD top_level.txt WHEEL

pip uninstall tensorflow-gpu and pip uninstall tensorflow should do it. Otherwise, you can also completely remove and reinstall anaconda to start from scratch.

Related

Why a python package shows different versions using __version__ and pip (same directory)

I have carefully checked the environment, and the two methods shows the same package directory:
>>> !pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org/
Author: The Astropy Developers
Author-email: astropy.team#gmail.com
License: BSD 3-Clause License
Location: /home/duhc/anaconda3/lib/python3.9/site-packages
Requires: packaging, numpy, PyYAML, pyerfa
Required-by: sdss-marvin, photutils, mgefit, gwcs
>>> import astropy
>>> print(astropy.__version__)
>>> print(astropy.__path__)
4.3.1
['/home/duhc/anaconda3/lib/python3.9/site-packages/astropy']
We see, the directories are the same, both are /home/duhc/anaconda3/lib/python3.9/site-packages, while the versions are different.
This does not happen in a fresh environment:
$>conda create -n astropy python=3.9.7 astropy=5.1
$>conda activate astropy
$>pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team#gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
$>python -c "import astropy; print(astropy.__version__)"
5.1
Also does not happen when the package is installed from pypi
$>conda uninstall astropy
$>pip install astropy
$>python -c "import astropy; print(astropy.__version__)"
5.1
$>pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team#gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
What probably happened is that you overwrote a pip installed package with conda. Complete steps to reproduce:
$> conda create -n astropy python=3.9.7
$> conda activate astropy
$> pip install astropy
$> pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team#gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
$> conda install astropy==4.3.1
$> pip show astropy
Name: astropy
Version: 5.1
Summary: Astronomy and astrophysics core library
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team#gmail.com
License: BSD 3-Clause License
Location: ...\miniconda3\envs\astropy\lib\site-packages
Requires: numpy, packaging, pyerfa, PyYAML
Required-by:
$> python -c "import astropy; print(astropy.__version__)"
4.3.1
Therefore it looks like this is not a bug of the package, but rather a good example of why you should be careful to not mix conda and pip commands in the same environment without care. I would especially advice against doing so in your base environment (personally, I would not change the base env at all, except for updates).

pip show and help("modules") don't agree

I am trying to install a company-internal package "algo_flows".
pip show algo_flows shows it
(py37) noam#9cae2d848b93:~$ pip show algo_flows
Name: algo-flows
Version: 1.0.0.dev36
Summary: UNKNOWN
Home-page: UNKNOWN
Author:
Author-email:
License: UNKNOWN
Location: /home/noam/.local/lib/python3.7/site-packages
Requires: anomalib, datetime, fastapi, matplotlib, ml-distillery, numpy, opencv-python, overrides, pydantic, pytest, pytest-dependency, pytest-order, pyyaml, torch, torchvision, uv-python-utils
Required-by: inspection-manager
but it can't be imported, and is not shown via help("modules")
There is no way I can create a reproducible of this, I have no idea what could cause this.
How can I debug it? pip install seems to work fine!

Cannot install Tensorflow on PyCharm

I am trying to install TensorFlow on PyCharm in Project > Python Interpreter to meet the requirement of the TF Developer Certificate exam.
My computer is Windows 10. On the Python Console, I print the python version:
>>> print(sys.version)
3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
Then I go to File > Settings > Project > Python Interpreter > Available Packages, find and install the Tensorflow package. I install the default version which is 2.2.0. My pip version is 20.1.1.
But I cannot install it, it displays this error:
Error occurred:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
Command output:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
I have searched for this solution but I cannot find anything that helps me solve it. Does anyone know how to fix this? Thanks.
Update:
When I install the TF in my cmd, it installs successfully.
C:\Users\User>pip show tensorflow
Name: tensorflow
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages#tensorflow.org
License: Apache 2.0
Location: c:\users\user\anaconda3\lib\site-packages
Requires: six, google-pasta, wrapt, astunparse, gast, wheel, scipy, absl-py, numpy, tensorboard, termcolor, grpcio, h5py, keras-preprocessing, tensorflow-estimator, protobuf, opt-einsum
Required-by:
Update 2:
I follow this set up instruction by TF: Link
Update 3:
So I tried to install via package location but it doesn't work (Python 3.7 CPU-only):
pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.2.0-cp37-cp37m-win_amd64.whl
Error:
ERROR: tensorflow_cpu-2.2.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
Update 4:
I create a new project, then use conda environment to install TF. Then it works.
But I still don't understand why using normal venv, it cannot install.
Update 5:
Everything works fine on Ubuntu when following the instruction by TF.
I had this issue when I was trying to use TensorFlow on Windows 10 while having multiple versions of Python installed.
What I did was uninstall all versions except the most updated one. If I needed an older version I would use Conda virtual environment.

Check and run correct Tensorflow Version (v2.0)

i was using the previous version of tensorflow, but i wanna use tensorflow 2.0.0 alpha and i've installed it with pip using
pip install tensorflow==2.0.0-alpha0
than i run the simple code to check what version
import tensorflow as tf
print(tf.__version__)
but this is the result:
1.13.0-rc1
so i check with pip
pip3 show tensorflow
and i got:
Name: tensorflow
Version: 2.0.0a0
Summary: TensorFlow is an open source machine learning framework for
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages#tensorflow.org
License: Apache 2.0
Location:
c:\users\massimo\appdata\local\programs\python\python37\lib\site-packages
Requires: gast, six, protobuf, google-pasta, absl-py, astor, tb-nightly,
termcolor, grpcio, keras-applications, keras-preprocessing, tf-estimator-
nightly, wheel, numpy
Required-by:
is there something wrong? i'm expecting with tf.version something like 2.0.0
what i'm missing?
Thank you all
Max
UPDATE
while the command
python -m site
sys.path = [
'C:\\Users\\Massimo\\AppVisualCode',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\python37.
zip',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\lib',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37',
'C:\\Users\\Massimo\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-
packages',
]
USER_BASE: 'C:\\Users\\Massimo\\AppData\\Roaming\\Python' (exists)
USER_SITE:
'C:\\Users\\Massimo\\AppData\\Roaming\\Python\\Python37\\site-packages'
(exists)
ENABLE_USER_SITE: True
if you have two interpreters both with python version 3+ upgrade your pip to version 0.8 or above for both the interpreters and then you can also do this
pip3.5 install package1
pip3.6 install package2
pip3.7 install package3
I was about to write the same answer as what Vlad wrote in the comment but because it didn't work for you & since you are already using multiple python interpreters,
another possible suggestion could be to use them in a different virtual environment (interpreters with different or same python versions) for all your new projects (it's also highly recommended by most of the Data Scientists).
After that install the packages with exact version that you want to use and you'll be good to go. You'll never have to worry about for which interpreter/environment you installed which package.

Where is the root directory of tensorflow installed when using it via Docker on windows?

I need to find out exactly where TensorFlow is installed when using it with the docker as I want to use the Inception-V3 image classifier to classify my own images. However, the tutorial on the website assumes I installed it using pip and thus I am stuck using the default image. Thanks!
You can find the details about tensorflow by typing pip show tensorflow from windows command line or powershell.
For me it showed the following details:
Name: tensorflow
Version: 0.12.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com License: Apache 2.0
Location: c:\program files\anaconda3\lib\site-packages
Requires: protobuf, numpy, six, wheel

Categories