Install PyTorch without installing Python 3.9 on Win7 - python

Got clean installation of Anaconda (Python 3.8.8), tried to install PyTorch by running conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch as suggested by the docs. The thing is, conda tries to install Python 3.9.7 in the process, which does not support Windows 7 (the famous "api-ms-win-core-path-l1-1-0.dll missing error"). Is there a way to make the installation of PyTorch without switching to the latest Python?

If you start with a clean package with a specific python version you could use the --freeze-installed flag to prevent the installer from making any changes to the installed packages, see documentation.

Related

jupyter runs an old pytorch version

I have elementary knowledge on package managers, so forgive me if my question is phrased badly.
I am using miniconda as a package manager. I have python 3.8 installed, and I use jupyter lab to run ipython kernels.
My issue is that when import torch then the version 1.7.1 is loaded to the notebook, however, when I look at conda list I see that version 1.8.1 of torch is installed.
When I try to update using conda update --all and conda update pytorch nothing is being installed.
So
I don't know why pytorch is not updated to the new version of 1.9.
I don't know why an older version 1.7.1 is loaded to my jupyter notebook.
would love to get some help!
I am not sure exactly what solved it, but:
I updated homebrew which required me to install some command line tools of x-code, and then I managed to install pytorch again using
conda install pytorch torchvision -c pytorch.
Now the proper version is loaded when I use jupyter.

Can't install tensorflow with pip or anaconda

Does anyone know how to properly install tensorflow on Windows?
I'm currently using Python 3.7 (also tried with 3.6) and every time I get the same "Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )
No matching distribution found for tensorflow-gpu" error
I tried installing using pip and anaconda, both don't work for me.
Found a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.
Tensorflow or Tensorflow-gpu is supported only for 3.5.X versions of Python. Try installing with any Python 3.5.X version. This should fix your problem.
Here is what i did to get tensorflow working with windows.
Download python 3.7.0 (64 bit from Python Releases for Windows) Install it and check python version by running below command in cmd:
python --version
Python 3.7.0
Then run below command to upgrade pip to latest
python -m pip install --upgrade pip
Now install tensorflow using pip
pip install tensorflow
That's it you have installed tensorflow on windows. Below image shows what happens when you type above commands
link for tensorflow for python 3x
https://pypi.org/project/tensorflow/#files
tensorflow-1.14.0-cp37-cp37m-win_amd64.whl (68.3 MB)
Unfortunately, tensorflow can't installed correctly on python 3.7 and last version of anaconda: so, the best and effective way to do this is to downgrade your python to python 3.6.7 use the next steps:
1- download the latest version of Anaconda
use Anaconda prompt with administrator privilege
2- conda install python=3.6.7 (need a long time)
3-conda install tensorflow
4- conda install keras
5- conda install numpy
Check whether you have a CPU or GPU, if your system doesn't have GPU, then it will generate error.
If you are going to install tensorflow using Windows command prompt (assuming python is already installed), then just run the following command. Go to the root directory, preferably 'C:' drive then run
For GPU- pip3 install --upgrade tensorflow-gpu
For CPU- pip3 install --upgrade tensorflow
If you are using Anaconda, then open Anaconda Navigator->Environments->Select 'All' from the drop down menu and then search TensorFlow. If you are using CPU, then select 'tensorflow', else for GPU select 'tensorflow-gpu'. Then click Apply.
Screenshot of Anaconda Navigator-In case you are not familiar where to look.
Download the latest version of anaconda from here
I'm using Anaconda 2019.03 for Windows Installer, Python 3.7, 64-bit
Upgrade pip as:
python -m pip install --upgrade pip
(a). Install tensorflow using pip3 as:
pip3 install --user --upgrade tensorflow
(b). If you installed anaconda with all users mode. The above
command will become:
pip3 install --upgrade tensorflow
Check installation success as:
python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
As of Feb 2020, Tensorflow is not supported for Python 3.8+
To make it work install a virtualenv w/ Python 3.7 from here: https://www.python.org/downloads/windows/
Tensorflow pip installation for python version 3.5-3.8 requires pip 19.0 or later, as mentioned in the official tensorflow documentation.
Here is a part of this documentation:
System requirements
Python 3.5–3.8
Python 3.8 support requires TensorFlow 2.2 or later.
pip 19.0 or later (requires manylinux2010 support)
Try running pip install --upgrade pip inside your python3 virtualenv.
You mentioned Anaconda. Do you run your python through there?
If so check in Anaconda Navigator --> Environments, if your current environment have got tensorflow installed.
If not, install tensorflow and run from that environment.
Should work.
I had the same problem that yours, happened that I had python at version 3.7. So for installing the Tensorflow with the GPU support I used:
py -3.6 -m pip install tensorflow-gpu
at a Virtualenv ambient. You can see the documentation behind on this website:
https://docs.python.org/3/installing/index.html
I think that this solution is better than downgrade the Python version.
Actually the easiest way to install tensorflow is:
install python 3.5 (not 3.6 or 3.7) you can check wich version you have by typing "python" in the cmd.
When you install it check in the options that you install pip with it and you add it to variables environnement.
When its done just go into the cmd and tipe "pip install tensorflow"
It will download tensorflow automatically.
If you want to check that it's been installed type "python" in the cmd then some that ">>>" will appear, then you write "import tensorflow" and if there's no error, you've done it!
As of November 2018, Tensorflow is not supported for Python 3.6.4+
What to do:
Downgrade Anaconda's Python from 3.7 or 3.6.5+ to 3.6.4
a. Open Command Prompt, find your Anaconda environment, and change your directory
where anaconda or where python
Example path and cd:
cd C:\ProgramData\Anaconda3\bin
b. While in anaconda3/bin in your Command Prompt, source activate your base Anaconda environment
source activate
c. In your Command Prompt, downgrade your base Anaconda environment
conda install python=3.6.4
d. Install Tensorflow
pip install tensorflow
Further reading:
http://docs.anaconda.com/anaconda/user-guide/faq/#how-do-i-get-the-latest-anaconda-with-python-3-5
As of July 2019, I have installed it on python 3.7.3 using py -3 -m pip install tensorflow-gpu
py -3 in my installation selects the version 3.7.3.
The installation can also fail if the python installation is not 64 bit. Install a 64 bit version first.
This is Manas working as a intern in COE-AI lab(CET,BBSR) under tech machindra.
We faced same error. After a little research, we found that there is a glitch in anaconda python 3.7. It does not install tensorflow through pip or conda install command, even if it does..produces same error..
Here is the solution, install conda environment for python=3.6:
go to the directory where conda is installed
cd anaconda3
conda create -n tensorflow python=3.6
conda activate tensorflow
conda install tensorflow python=3.6
python
Import tensorflow.
steps
Do it twice:
enter image description here
enter image description here
-> Not able to install tensorflow , Here I have a solution that worked for me
Step 1 :
- Check version of python(3.7.3)
- Python must be 64 bit Otherwise tensorflow never ever going to be installed it defiitely gives Error.
Step 2 :
pip install tensorflow==2.0.0
Step 3 :
pip install sklearn==0.0
pip install Pillow==8.0.1
pip install h5py==2.10.0
Step 4 :
pip install keras==2.3.1
Now its ready to use.
In Windows 10 with Python 3.8.5, first i tried directly then it was giving following error:
ERROR: Could not find a version that satisfies the requirement tensorflow==1.15 (from versions: none)
Then i installed successfully in virtual environment shown below:
PS E:\udemy\full_stack_web_ai\deeplearning> .\myenv\Scripts\activate
(myenv) PS E:\udemy\full_stack_web_ai\deeplearning> pip install tensorflow
Collecting tensorflow ###
Downloading tensorflow-2.4.1-cp38-cp38-win_amd64.whl (370.7 MB)
Use virtual environment using:
python -m venv myenv
.\myenv\Scripts\activate
Not Enabling the Long Paths can be the potential problem.To solve that,
Steps include:
Go to Registry Editor on the Windows Laptop
Find the key "HKEY_LOCAL_MACHINE"->"SYSTEM"->"CurrentControlSet"->
"File System"->"LongPathsEnabled" then double click on that option and change the value from 0 to 1.
3.Now try to install the tensorflow it will work.

Tensorflow install fails with "compiletime version 3.5 of module does not match runtime version 3.6"

I tried installing from pip:
pip3 install --user --no-cache https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp36-cp36m-linux_x86_64.whl
Then tried importing and got:
Using TensorFlow backend.
/usr/lib64/python3.6/importlib/_bootstrap.py:205: RuntimeWarning:
compiletime version 3.5 of module
'tensorflow.python.framework.fast_tensor_util' does not match runtime
version 3.6
return f(*args, **kwds)
2017-11-10 09:35:01.206112: I
tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports
instructions that this TensorFlow binary was not compiled to use: SSE4.1
SSE4.2 AVX
Questions:
I don't understand why the wheel says 3.6, but I get the warning about 3.5
I want to compile to optimize for my cpu, so can I use pip to install from source rather than from binary wheel?
RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
This is a known issue, which is got prioritized and likely to be fixed soon. Right now the workaround is to use python 3.5.
UPDATE:
The issue has been fixed in the nightly tensorflow builds: "tf-nightly and tf-nightly-gpu now has a python3.6 binary built from scratch for Linux."
I.e., the following command should work with python 3.6:
# tf-nightly or tf-nightly-gpu
pip3 install tf-nightly
Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
This warning comes from the fact that the default tensorflow distributions are compiled without CPU extensions support (more on this here). If you want to get a CPU optimized tensorflow package, your only option is to build it yourself. It's a bit tedious, but absolutely doable. The build will produce the wheel file, which you can install with just
pip3 install /path/to/the/tensorflow.whl
But if you just want to suppress the warning, this will do:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
I got the same issue and I was able to solve it by installing 1.3 version rather than using 1.4 of tensorflow. Use the following command to do so.
pip3 install tensorflow==1.3.0
I encountered the same problem and I fixed it by:
pip install --ignore-installed tensorflow
The problem occurred because I complied a local version of tensorflow (to enable some CPU features) with python 3.5 earlier. I installed python 3.6 recently and the new tensorlfow already supported those CPU features, so I just installed the official version.
Update:
After some update of tensorflow the approach above doesn't work any more.
Another workaround is using virtual environment such as anaconda to create a python3.5 environment:
conda create -n py35 python=3.5
source activate py35
pip install tensorflow
To work with ipython or jupyter notebook, be sure to install ipykernel inside the virtual environment:
pip install ipykernel
Just install 1.3 version of tensorflow. Problem solved.
pip install tensorflow==1.3.0
solution 1.
the way I solved this is by downgrading to the latest python3.5, go to python.org download the latest Python3.5, install it and then use normalpip3 install tensorflow this should be able to fix the issue if not try the second solution.
solution 2(also you need to downgrade from python3.6 to python3.5
I used Pycharm to solve the issue, I created a project inside the pycharm editor then I changed the Project Interpreter from python3.6 to python3.5, to do this as well go to File > Preferences search for Project Interpreter, and from the drop-down menu change from python3.6 to python3.5
hit Apply wait for the operation to finish
and then in the same window using the + icon
A window will appear that will let you search and install python libraries easily without using pip, in our case we want tensorflow, so just search tensorflow, select tensorflow on search result and click Install Package this will install the package
and voila you're ready to roll, now you got tensorflow installed on your python3.5, keep that in mind.
For now you can use python version less than 3.6.x because now Tensorflow 1.4.0 is not working properly with python 3.6.x. It will surly work.
This issue was resolved on ubuntu 17.10 by running
$ conda install tensorflow
i use tensorflow 1.4.0, meet the same problem. but you can use tensorflow 1.6.0, now.

How to downgrade tensorflow, multiple versions possible?

I have tensorflow 1.2.1 installed, and I need to downgrade it to version 1.1 to run a specific tutorial. What is the safe way to do it? I am using windows 10, python 3.5. Tensorflow was installed with pip3, but "pip3 show tensorflow" returns blank.
Is it possible to have multiple version of tensorflow on the same OS?
Pip allows to specify the version
pip install tensorflow==1.1
I discovered the joy of anaconda: https://www.continuum.io/downloads. It allows multiple virtual environments to host different versions of phyton and tensorflow. For example the following creates a virtual environment with pyton3.5 and tensorflow1.1
C:> conda create -n tensorflow1.1 python=3.5
C:> activate tensorflow1.1
(tensorflow1.1)
C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl
voila, a virtual environment is created.
Is it possible to have multiple version of tensorflow on the same OS?
Yes, you can use python virtual environments for this. From the docs:
A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
After you have install virtualenv (see the docs), you can create a virtual environment for the tutorial and install the tensorflow version you need in it:
PATH_TO_PYTHON=/usr/bin/python3.5
virtualenv -p $PATH_TO_PYTHON my_tutorial_env
source my_tutorial_env/bin/activate # this activates your new environment
pip install tensorflow==1.1
PATH_TO_PYTHON should point to where python is installed on your system.
When you want to use the other version of tensorflow execute:
deactivate my_tutorial_env
Now you can work again with the tensorflow version that was already installed on your system.
If you are using python3 on windows then you might do this as well
pip3 install tensorflow==1.4
you may select any version from "(from versions: 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0)"
I did this when I wanted to downgrade from 1.7 to 1.4
Pay attention: you cannot install arbitrary versions of tensorflow, they have to correspond to your python installation, which isn't conveyed by most of the answers here. This is also true for the current wheels like here (from this answer above). For this example, the cp35-cp35m found inside the url hints that it is for Python 3.5.x
A huge list of different wheels/compatibilities can be found here on github.
By using this, you can downgrade to almost every availale version in combination with the respective for python. For example:
pip install tensorflow==2.0.0
(note that previous to installing Python 3.7.8 alongside version 3.8.3 in my case, you would get this:
ERROR: Could not find a version that satisfies the requirement tensorflow==2.0.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1)
ERROR: No matching distribution found for tensorflow==2.0.0
this also holds true for other non-compatible combinations.)
This should also be useful for legacy CPU without AVX support or GPUs with a compute capability that's too low.
If you only need the most recent releases (which it doesn't sound like in your question) a list of urls for the current wheel packages is available on this tensorflow page. That's from this SO-answer.
Note: This link to a list of different versions didn't work for me.
You can try to use the options of --no-cache-dir together with -I to overwrite the cache of the previous version and install the new version. For example:
pip3 install --no-cache-dir -I tensorflow==1.1
Then use the following command to check the version of tensorflow:
python3 -c ‘import tensorflow as tf; print(tf.__version__)’
It should show the right version got installed.
If you have anaconda, you can just install desired version and conda will automatically downgrade the current package for you.
For example:
conda install tensorflow=1.1
Click to green checkbox on installed tensorflow and choose needed version
You can downgrade TensorFlow version to a lower version by running:
1.Check the version of TensorFlow that currently installed by:
pip3 show tensorflow
2.Then, Downgrade TensorFlow to a lower version by running:
pip3 install --upgrade tensorflow==<version>
Set the version to a lower number than the currently installed release. When choosing, make sure the version is compatible with the Python release.
If you are using a Notebook environment, run the following command and restart the kernel when the installation completes:
!pip install --upgrade tensorflow==<version>
Although the best practice is to use the latest version of Python and
TensorFlow since older versions have vulnerability issues. So be
cautious when downgrading.

Tensorflow r1.0 : could not a find a version that satisfies the requirement tensorflow

I want to install Tensorflow 1.o for python on windows.
This is information for my system.
D:\>python --version
Python 3.5.2 :: Anaconda 4.2.0 (32-bit)
D:\>pip3 --version
pip 9.0.1 from d:\web\anaconda\lib\site-packages (python 3.5)'
But, when I execute below command,
D:\>pip3 install tensorflow
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
I don't understand what the problem is...
And I tried another way...
This is case when I use Conda
(tensorflow) D:\>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl
tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl is not a supported wheel on this platform.
What is the problem?
I was in same problem.
Below command solved my problem
pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py3-none-any.whl
to find the list of all the urls based on the python version and CPU or GPU only refer to:
https://www.tensorflow.org/install/pip
Tensorflow requires a 64-bit version of Python.
Additionally, it only supports Python 3.5.x through Python 3.8.x.
If you're using a 32-bit version of Python or a version that's too old or new, then you'll get that error message.
To fix it, you can install the 64-bit version of Python 3.8.6 via Python's website.
Tensorflow on windows needs python 3.5. You can follow following steps to activate python 3.5 in anaconda:
See which version of python you have: conda search python
If you already have python 3.5 then go to step 3
otherwise use conda create -n py35 python=3.5 anaconda to create python 3.5
Activate python 3.5 using activate py35
Now install tensorflow using conda install tensorflow
If step4 is not working i.e, something like "tensorflow: no package found " then follow this tutorial to forge conda-forge channel and then try installing tensorflow using step4. It worked for me.
Try this
Installing with Anaconda
conda create --name tensorflow python=3.5
activate tensorflow
conda install jupyter
conda install scipy
pip install tensorflow
or
pip install tensorflow-gpu
It is important to add python=3.5 at the end of the first line, because it will install Python 3.5.
I was getting the same error
Get Python 3.5
Upgrade pip version to 9
Install tensorflow
It worked for me
I did it with:
python3 -m pip install --upgrade tensorflow
From your python version output, looks like that you are using Anaconda python, in that case, there is a simple way to install tensorflow.
conda install -c conda-forge tensorflow
This command will take care of all dependencies like upgrade/downgrade etc.
upgrading pip worked for me
python -m pip install --upgrade pip
i had python 3.8.5 ..but it will not work with tenserflow..
so i installed python 3.7.9 and it worked.
The solution for me was sooo dumb!!
I was using Python 3.8 in my environment. I made a new environment using Python 3.7, and the install worked fine.
source
The TensorFlow package couldn't be found by the latest version of the "pip".
To be honest, I really don't know why this is...
but, the quick fix that worked out for me was:
[In case you are using a virtual environment]
downgrade the virtual environment to python-3.8.x and pip-20.2.x
In case of anaconda, try:
conda install python=3.8
This should install the latest version of python-3.8 and pip-20.2.x for you.
And then, try
pip install tensorflow
Again, this worked fine for me, not sure if it'll work the same for you.
The Reason is that TensorFlow is only available upto python versions <= 3.6. You can't download tensorflow for python versions > 3.6 as there is no tensorflow.
If you don't want to downgrade your entire python version for a single package, do this:
create a new virtual environment for that project (using anaconda)
conda create -n <env_name> python=3.6.8
activate the created environment using conda activate <env_name>
Now install pip install tensorflow
note: If tensorflow dosen't install : try install keras module first and then try installing tensorflow

Categories