Installing TensorFlow in python 3.5 Anaconda distro conda env - python

What I did to try and solve this issue:
Using Mac OS X
Using Anaconda distro currently in my computer as the path /Users/hongshuhong/anaconda/
Used conda instead of virtualenv because of my distribution of python. I referred to the guide here and tried to download the same with conda's package manager: https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
Tensorflow worked correctly when I created an anaconda env using the command conda create --name ML python=2.7 anaconda to state I'm using 2.7 python, then used this command conda install -c https://conda.anaconda.org/jjhelmus tensorflow
gathered from the Anaconda Cloud to attempt to download it. It worked when I said
$ python
>>> import tensorflow as tf
...
However, it doesn't really fix the issue:
However, I want to use the 3.5 distribution of python, simply to keep up with the times and not use outdated pythons.
I attempted to download it using the same way in python=3.5, but it raised this error when I tried to run the command conda install -c https://conda.anaconda.org/jjhelmus tensorflow :
Hint: the following packages conflict with each other:
- tensorflow
- python 3.5*
Use 'conda info tensorflow' etc. to see the dependencies for each package.
And I ran the conda info tensorflow to see what was going on and I got:
Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: tensorflow
This is really frustrating me and I'm not sure what to do. If there's no work around for this, I think I'll have to use Anaconda's python 2.7 distribution for TensorFlow experiments. If anyone has any idea how to solve this compatibility issue(or some other kind of issue), I'd be extremely grateful. Thanks.
EDIT: I'm pretty sure TensorFlow supports 3.5 because in their documentations they say they support 2.7 python and 3.3+. If there were no clues as to whether they support 3.5, I would have already given up and used 2.7 by now.

The version of TensorFlow packaged here is version 0.5.
Python 3.x support was introduced in TensorFlow 0.6, so you need to figure out how to install the newest version into Anaconda.
Usually you can install packages into anaconda using pip, but I haven't succeeded with TensorFlow.
EDIT: I just noticed that the documentation hasn't updated the url to the pip-wheel.
To install tensorflow in python 3.5 via pip, use the following command:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
This links to ...tensorflow-0.5.0-py2-none-any.whl, which is an older version of tensorflow for python 2.x.
Tensorflow get started page link.

Related

Tensorflow-text: NotFoundError: _text_similarity_metric_ops.so not found

import tensorflow-text
Actually i'm trying to run on Windows 10 (Pro), version 1909.
Attempts to run on Python 3.8.5, 3.6.13, and 3.7 brought no result - i've got the same error.
Using Jupiter Notebook, conda (4.10.1)
Version of Tensorflow - 2.1.0
Downloading version of Tf-text is "tensorflow_text-2.4.3-cp36"
Now i'm trying to reinstall conda, switch tensorflow versions
I hope this issue will be fixed soon.
So, this problem was solved easy by myself!
All you have to do is:
Setup conda enviroment, in Anaconda
Then in Anaconda cmd run conda activate <your_enviroment_name>
pip install tensorflow==2.4.1, pip install tensorflow-text==2.4.1
Then it should works.
Remember, run on Python 3.7.10
Also guys from tensorflow says that you can run it on python 3.6 and 3.8, but be carefully with TF 2.4.1, i saw some info that Python 3.6 could not run just that current version.
Best wishes,
Temio

Current working method to install zipline? tried everything

Hey im trying to install zipline on Python but nothing works
I already tried it with Python 3.7 but it fails at the following libaries bcolz
lru dict
bottleneck
cyordereddict
(and zipline itself)
I tried it with Python 3.5 as recommended in this guide (https://pythonprogramming.net/zipline-local-install-python-programming-for-finance/)
same results.
I tried it creating an anaconda environment with pyhton 3.5 ... again same results.
the only thing that "worked was installing it without dependencies, but then i would have to install trading-calendars and some other libaries (which also didnt work to install):
pip install --no-deps zipline-1.3.0-cp37-cp37m-win_amd64.whl
Could somebody tell me a current working method on installing zipline?
zipline is as of now, not compatible with python version > 3.5 and is very specific to versions of dependent packages. Most of these packages has new versions.
https://github.com/quantopian/zipline/issues/2514
Best method would be to install with conda.
Once you had installed Anaconda/Miniconda you need to downgrade it to 4.6.11, below commands may help.
conda config --set allow_conda_downgrades true
conda install conda=4.6.11
conda create -n env_zipline python=3.5
activate env_zipline
conda install -c Quantopian zipline
To install zipline simply run in your new virtual env:
pip install -e git://github.com/shlomikushchi/zipline-trader.git#egg=zipline-trader
For more info:
Check Docs
Edit on GitHub
Lear from video tutorial
Read blog - Linear Regression For a Momentum Based Trading Strategy Using Zipline Trader
Chat on Slack

Could not find a version that satisfies the requirement torch>=1.0.0?

Could not find a version that satisfies the requirement torch>=1.0.0
No matching distribution found for torch>=1.0.0 (from stanfordnlp)
This can also happen if your Python version is too new. Pytorch currently does not support past 3.7.9.
Figured out from: https://stackoverflow.com/a/58902298/5090928
This is the latest command for pytorch.
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
I had some difficulties with this as well. The steps I had to do was:
Install the latest version of PyTorch:
pip3 install torch===1.3.1 torchvision===0.4.2 -f
https://download.pytorch.org/whl/torch_stable.html
Make sure you are installing with 64bit python version; otherwise, it won't work
I finally managed to solve this problem thanks to John Red' comment and serg06 answer. Here's what I've done :
Install Python 3.7.9 and not newer.
BUT make sure to install 64bits python
Every other combination failed for me.
I had this same issue while installing standfordnlp in my windows 10 system.
Installing torch before installing stanfordnlp worked out for me.
I have installed torch from pytorch official website.
Use 64-Bit Python. PyTorch doesn't work with 32-Bit Python. I had the same issue.
For people visiting this questions with slightly newer versions of python and pytorch, I had Python 3.8.3 32-bit and even though the pytorch page states that:
Currently, PyTorch on Windows only supports Python 3.7-3.9;
Installing Python 3.9.13 64-bit instead of Python 3.8.3 32-bit solved it for me.
After that, I used the install script generator and ran
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
... and it started downloading.
If you have python 3.7 already installed along with newer versions then can use below command to install torch using python 3.7
py -3.7 -m pip install torch
But also note that you have to execute the python program using py -3.7
py -3.7 program_name.py
torch and torchvision need python 3.8.x ... so in your CLI run
python --version
to get the python version.
make sure that your environment has python 3.8.x, otherwise, create another virtual environment with anaconda
conda create -n myenv python==3.8 anaconda
conda activate myenv
Then install torch and torchvision by this command
pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
I went heaven and earth for this problem and here is what it turned out to be:
1- i had python 3.10
2- the python.exe in my virtual environemnt linked to python310
i uninstalled the python3.10 , then went to delete the paths in system environemnts variables (go to windows search, type this thing, you get a window, click on environment variables, and find a word called paths, click edit) ....\python310\ (i named as such when initially installed, you probs have another name) and also this ...python310\Scripts\
delete them
go to https://www.python.org/downloads/release/python-3711/ , istall pythion 3.7 , after that go back to system env. variables thingy, .. add the paths that ends with ...\python37\ , and ...\python37\Scripts\ (make you sure you end the paths with "")
then go to new command prompt, type python , you should get Python 3.7.0 ...
cd to your virtual environment path script (mine looked like this C:\Users...\python_ver\python_projects\root_environment\Scripts>) , activate to the name of whatever you called, for me i typed: activate tf.
type python again, if you have python 3.7 as a result, you good to go ... if you still seeing python 3.10 ... then you probs get some error saying no python in ....\python310\python.exe ... so:
go the folder that you saved python310 (the path shown in the last step), make sure all folders of your python 3.7 go in there.
type python in cmd in the same virtual envrioment path by the cursor ... to check you running pythong 3.7 ...
once python 3.7 is your default .. run the blood Clot for pytorch https://pytorch.org/ to install pytorch
thanks to all the guys on this
I tried every possible command for Windows, but nothing worked. I also tried using Pycharm package installation, everything throws the same error.
Finally installed Pytorch using Anaconda.
For previous versions please use the snippets from the PyTorch website; https://pytorch.org/get-started/previous-versions/
As an example, this will turn into an error since the cudatoolkit versions are not listed in pip;
!pip install torch==1.10.0+cu111
ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu111 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0) ERROR: No matching distribution found for torch==1.10.0+cu111
For the same Torch version and cudatoolkit, you can use the following code instead;
!pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
import torch
TORCH_VERSION = ".".join(torch.__version__.split(".")[:2])
CUDA_VERSION = torch.__version__.split("+")[-1]
print("torch: ", TORCH_VERSION, "; cuda: ", CUDA_VERSION)
Result:
torch: 1.10 ; cuda: cu111
I want to pip install " torch>=1.4.0, torchvision>=0.5.0 ", but in a conda env with python=3.0, this is not right.
I tried create a new conda env with python=3.7, and pip install " torch>=1.4.0, torchvision>=0.5.0 " again, it is ok.
This is for Deep Reinforcement Learning: Chapter-6: 02_dnq_pong.py:
I did not verify the above solutions. I found it tedious to change the existing library version.
So, as mentioned by someone in GIT, you just have to change two variables in your loss function.
https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On/issues/90
Change the variables to below:
actions_v = torch.tensor(actions).to(device, dtype=torch.int64)
done_mask = torch.tensor(dones).to(device, dtype=torch.bool)
You could make similar changes to the variables which cause the error, in your respective programs.
I had the same issue with Python 3.8.2 which is currently supported by PyTorch. I updated pip from version 19.2.3 to 22.3.1 and my issue was solved:
pip install --upgrade pip
Use a virtual environment with Python 3.7.9
Go to the python version download page (with binary installers) https://www.python.org/downloads/release/python-379/
Go to that page and download Windows x86-64 embeddable zip file
extracted the zip file and placed the contents inside the project folder.
Then used,
virtualenv --python .\python379\python.exe env
To create the virtual environment by specifying the exe location.
Now activate it using .\env\Scripts\activate and you should be able to install.
If you get any error like virtualenv: The term 'virtualenv' is not recognized as a name of a cmdlet, uninstall virtualenv using pip uninstall virtualenv, close the terminal, open terminal as
Administrator / root user and install again.
follow the link: https://pytorch.org/
and set your system requirement in QUICK START LOCALLY SECTION

How can I change between versions of python 3

I am trying to use tensorflow but my python is to recent. I have python3.7.2 and I need py3.6 in order to install and use tensorflow.
I have installed py3.6.8 but I still can't install it with pip. Is there a way of interchanging between versions of python to install/use tensorflow. Or is it to do with my pip version?
The error is:
Could not find version that satisfies the requirement tensorflow in versions:
The main problem is that I don't know how to get tensorflow. Can someone help me do this?
By far the best option will be to use Anaconda virtual environment. After you install Anaconda, use environments to manage different versions of Python:
Python 3.6.8:
conda create -n myenv python=3.6.8 tensorflow
Python 3.7:
conda create -n myenv python=3.7 tensorflow
Why am I saying it's best with Anaconda? Long story short, it can be (much) faster. Here's an article that discusses why.
Option 1:
Install multiple versions in separate directories, and then you run the python program with the Python version you want to use. Like so:
C:\Python26\Python.exe thescript.py
What virtualenv does is that it gives you many separate "virtual" installations of the same python version. That's a completely different issue, and hence it will not help you in any way.
Option 2:
Use Pythonbrew.
Once pythonbrew is installed:
#to install new python versions is as simple as:
pythonbrew install 2.7.2 3.2
#to use a particular version in the current shell:
pythonbrew use 3.2
#to uninstall:
pythonbrew uninstall 2.7.2

ImportError: No module named 'tensorflow' using anaconda + windows

Pip Installed tensor flow (CPU only... https://www.tensorflow.org/install/install_windows) in an anaconda environment, says it successfully installed but when I go to use tensor flow (with environment activated) it displays an error saying "ImportError: No module named 'tensorflow'".
However, After i installed pandas package, and it successfully runs. i ran an update to python=3.5 for the environment (because my anaconda is 2.7 version), and tried using this link https://github.com/tensorflow/tensorflow/issues/6136 for help also. Weird that other packages run but not tensor flow. Using a PC windows 10 with intel CPU and amd graphics. Any suggestions would be helpful.
First check which environment you are using right now.
If it helps open the anaconda navigator and see whether you have TensorFlow installed in the "installed" tab of that particular environment.
Check the following on jupyter noteook and see what python version you're using in that environment because the environment that you are using might have a different python version after all.
from platform import python_version
print(python_version())
If the versions are different, try removing the TensorFlow installation and reinstalling it according to your python version. environment and recreating the same environment pip install --ignore-installed --upgrade tensorflow=='version_for_your_requirement"
If the situation is still there, https://www.youtube.com/watch?v=tPq6NIboLSc see here the steps followed in the video. Though its a slightly different scenario, you will get the gist of it pretty quickly as to how we can make another environment for our work and about installing TensorFlow properly.
Tensorflow supports 64-bit Python version. Make sure you have installed 64-bit Python 3.5/3.6/3.8 version.
Install Tensorflow using following steps
#check current python version
python --version
#Create the virtual environment
conda create -n tf python=PYTHON_VERSION
#Activate the tf environment
conda activate tf
#Install Tensorflow
pip install tensorflow

Categories