Tensorflow issues when downloading and importing - python

I'm trying to use tensorflow more accurately keras but it used tensorflow backend. I have had to convert my python to 3.6.2 in order to download tensorflow and even though it installs when I go to import it doesnt work saying :
ModuleNotFoundError: No module named 'tensorflow'
So i have tried installing Anaconda and performing this input:
conda create -n tensorflow_cpu pip python=3.6 #also tried with just tensorflow
activate tensorflow_cpu
pip install --ignore-installed --upgrade tensorflow
Then I get this error:
ERROR: Could not find a version that satisfies the requirement tensorflow_cpu (from versions: none)
ERROR: No matching distribution found for tensorflow_cpu
So now I am completely stuck. Why is it so hard to just import a module. Why hasn't tensorflow made the effort to make it work with newer versions of python. I am trying to perform machine learning projects but this issue is demotivating me massively and is turning me away from it all together.
If anyone has a solution or reason could you please let me know it simple matters so i can follow thoroughly. Thanks for your time.

If you are on Windows install Python 3.6.x and then Tensorflow as of 8-13-2018 and if you are on Linux just follow this link's instruction https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html .

Related

Setting up keras-rl2 on my M1 Macbook Pro

I am working on a project on Reinforcement Learning - and completely new at this. I installed keras-rl as
pip install keras-rl, however it caused an error as many has mentioned:
TypeError: Keras symbolic inputs/outputs do not implement `__len__`. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly.
And the solution for this is to used keras-rl2. Howver I cannot install keras-rl2 on my Mac M1 as the output is following:
ERROR: Cannot install keras-rl2==1.0.0, keras-rl2==1.0.1, keras-rl2==1.0.2, keras-rl2==1.0.3, keras-rl2==1.0.4 and keras-rl2==1.0.5 because these package versions have conflicting dependencies.
When I tried a specific version, i.e
pip install keras-rl2==1.0.5, the output is:
ERROR: Could not find a version that satisfies the requirement tensorflow (from keras-rl2) (from versions: none)
ERROR: No matching distribution found for tensorflow
I have tensorflow 2.6.0 installed by Apple Developer guide. Any idea how I can install keras-rl2?
1. To install Tensorflow on M1 Macs
https://developer.apple.com/metal/tensorflow-plugin/
2. To Install Keras-rl2
Open a terminal window and run these commands from:
https://github.com/keras-rl/keras-rl (last line changed)
git clone https://github.com/wau/keras-rl2.git
cd keras-rl
python3 setup.py install
The setup.py script will still tell you that it can't find a TensorFlow version but you will still be able to import it using:
import rl

Python package (tensorflow) displays mismatching versions between pip list and .__version__ output

I suddenly encounter this situation today, all below output is under the same environment.
pip show tensorflow, the output gives:
Name: tensorflow
Version: 1.14.0rc1
But, if I enter python
python
>>> import tensorflow as tf
>>> print(tf.__version__) . It gives:
'1.13.1'
I am sure I am using the same python under the environment I need with pure terminal or in IDE. This is weird, cuz I used to not having this issue. I just installed few other packages these two days, but I believe they have nothing to do with tensorflow. And you can also verify this through pip show tensorflow or pip list output to see the version is 1.14.0rc1. So why when I actually use python, the tensorflow is not loaded properly?
Solved it by the following:
(under the same environment)
pip uninstall tensorflow (in order to reinstall tensorflow the right version)
pip install tensorflow==1.14.0rc1
Note during installing, there is a piece of info from the terminal:
Installing collected packages: tensorflow
Attempting uninstall: tensorflow
Found existing installation: tensorflow 1.13.1
Uninstalling tensorflow-1.13.1:
Successfully uninstalled tensorflow-1.13.1
So it seems like the tensorflow 1.13.1 has been accidentally installed previously, and whenever in a python program import tensorflow, during searching stage, it hits the tensorflow==1.13.1 before finding the 1.14.0rc1 version. Altho pip list only displays tensorflow==1.14.0rc1 but not tensorflow==1.13.1 might also be due to its internal search or duplicated package resolve mechanism.

Installing a specific version of sklearn

I have been trying to run a example code which imports sklearn.When I tried to run it using the latest version I got the below error.
UserWarning: Trying to unpickle estimator pipeline from version 0.21.3
when using version 0.23.1. This might lead to breaking code or invalid
results. Use at your own risk.
And the program stops executing after this.
Many threads suggested that I should use the same version of sklearn which is 0.21.3.
So then I tried uninstalling sklearn and ran this command in my command line.
pip install sklearn==0.21.3
But then I got the error saying ,
Could not find a version that satisfies the requirement
What do I have to do in order to install sklearn 0.21.3 correctly using pip on windows?
Additional info : I am using python 3.7 on windows 10
As Alex stated, you need use to the full name of the module, uppercase is indifferent in this case. Both pip install scikit-learn==0.21.3 or pip install Scikit-learn==0.21.3 will work as I just tested it and I got a successful installation.

SciPy can't install old version Windows 10

I'm trying to install an older version of SciPy (either 0.16.1 or 0.17.0), but when I try to use pip I get the result:
pip install scipy==0.16.1
I get the following message
Failed building wheel for scipy
So I found the .whl file here https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy but the problem is that the version here is 1.0.1, and I can't seem to find any older ones, even in the SciPy website (there are for linux and mac)
.
.
PS.
I need to use either of this versions because I'm trying to run Theano on a GPU, and the tutorial provided here http://deeplearning.net/software/theano/install_windows.html says this version is a requirement if there is any tutorial that is better and more up-to-date I would be appreciated

How to install keras on Win10?

I know there are a lot of tutorials of installing keras on win. But I am faced with a weird problem and I cannot find a solution on Google.
The version of python I used is 2.7(anaconda 64bit).
When I typed 'pip install keras' in cmd, an error occurred.
It is said that no matching distribution found for tensorflow(from keras).
I googled it and one saying goes that this problem occurred when python is 32bit on windows. However, my python is 64-bit, so this saying does not hold.
I want to know how to handle this, given that I want to use theano as keras backend instead of tensorflow.
I think the problem is that TensorFlow on Windows only support Python 3.5.X.
You should try installing anaconda3.
Source: https://www.tensorflow.org/install/install_windows
using commad pip install -v -v -v keras may offer you more information about this
and I find this commad may download Keras tar file in site https://pypi.python.org/simple/keras/
and after download file, it will check the requires.txt in Keras.egg-info
then i find in Keras 2.0.0 it require tensorflow instead of theano in this version, otherwise you may fail to install
so the solution is, download the other keras in site which requires theano not tensorflow, and unpack it, then cd its directory, and use python setup.py install to install this version of keras

Categories