How can I fix the error "Could not find a version that satisfies the requirement torch" when trying to install PyTorch using pip? - tensorflow

I tried importing 'PyTorch' as 'torch' as most recent, but visual studios/cmd cannot locate nor download the package.
# Import the required modules import torch import torch.nn as nn import torch.nn.functional as F
same goes with
import tensorflow as tk
I wasn't able to download the package:
not able to find the file.
I tried both:
pip install --upgrade pip
and:
pip install torch==1.0.2
I tried all types such the basic pip install [package] to connecting the wsl.file through path

Installing older torch needs --find-index flag to pip, like torch 1.5 with cuda 10.1:
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
Reference:
https://pytorch.org/get-started/previous-versions/

Related

Importing TensorFlow "async" syntax error

I am trying to use the module imageai for a project and ran the line "from imageai.Detection import ObjectDetection". However, when I do so, this error appears:
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/pywrap_tensorflow_internal.py:114
def TFE_ContextOptionsSetAsync(arg1, async):
^
SyntaxError: invalid syntax
I found someone who had the same issue here: https://github.com/tensorflow/tensorflow/issues/20690 , but I'm not quite sure how to edit the last file of the trace where the error occurs. Does anyone have any tips on how to do this? Thanks!
I have tried looking at the above GitHub error but am not sure how to approach it.
ImageAI uses Pytorch as backend. So you need to install all the required libraries before installing and importing the imageai module.
Please use the code below to install imageai in your system:
pip install cython pillow>=7.0.0 numpy>=1.18.1 opencv-python>=4.1.2 torch>=1.9.0 --extra-index-url https://download.pytorch.org/whl/cpu torchvision>=0.10.0 --extra-index-url https://download.pytorch.org/whl/cpu pytest==7.1.3 tqdm==4.64.1 scipy>=1.7.3 matplotlib>=3.4.3 mock==4.0.3
pip install imageai --upgrade
Now, import the Object detection from imageai:
from imageai.Detection import ObjectDetection
Please refer this link for more details.
Note: You can easily install imageai in Google Colab with this code
!pip install imageai
from imageai.Detection import ObjectDetection
Hints: Please use below code to install, import and check the TensorFlow version
pip install tensorflow
import tensorflow as tf
tf.__version__

How to Install tensorflow addons via conda

I cannot find it out. Does Conda support it?
conda install tensorflow-addons
cannot find out the package
You can find information related to TensorFlow Addons here. Currently, it looks like Conda does not support Tensorflow Addons yet. You will have to wait for it to be implemented in the future. Otherwise, you can use pip install tensorflow-addons.
You can use pip in your Anaconda environment to install tensorflow-addons.
pip install tensorflow-addons
then to use:
import tensorflow_addons as tfa
I was able to successfully import it and use InstanceNormalization
conda install -c esri tensorflow-addons
or
conda install -c esri/label/prerelease tensorflow-addons
https://anaconda.org/esri/tensorflow-addons
To install the latest version of addons, run the following:
pip install tensorflow-addons
To use addons:
import tensorflow as tf
import tensorflow_addons as tfa
For more information please refer the below link
Tensorflow-addons

Python cannot find Tensorflow module

With Python3.5, I try to use the 'tensorflow' module:
import tensorflow as tf
But.. it says No mudule named tensorflow
I just tried to download the module with pip3:
pip3 install --upgrade tensorflow-gpu
(I have all the requirements to run tensorflow with GPU support as described at tensorflow.org)
I've seen a similar question here ImportError: No module named tensorflow , here's a sum up of what's inside:
Make sure installation is correct via:
pip3 show tensorflow
You can optionally re-install it again using: pip install tensorflow==1.2.0 --ignore-installed
Make sure you're running the python code with Python 3.x, verify using: python --version
Make sure you install TF and run the script through the same user, avoid installing TF using sudo pip install... and running the code with python script.py

Cant import keras

I ran the following on my Anaconda command prompt for python 3.6:
pip install keras
Next, typing the following on Spyder:
import keras
The above gives me an error:
No module named 'tensorflow'
Tring to do pip install tensorflow on the Anaconda command prompt gives me the follwing error:
No matching distribution found for tensorflow
To install a module into anaconda, use
$ conda install tensorflow
The command that you ran
$ pip install tensorflow
will not install it inside the anaconda virtualenv for python.
If you try
$ python
>>> import keras
This will work after pip install tensorflow. However, use conda package manager to install modules to anaconda.

error of import tensorflow as tf python 3.6.0

I downloaded the tensorflow package for python3.6.0 from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy then installed it by pip, it showed successful . when I import tensorflow as tf,it failed like following
import tensorflow as tf
From Documentation
Install TensorFlow Python dependencies
To install TensorFlow, you must install the following packages:
numpy, which is a numerical processing package that TensorFlow requires.
dev, which enables adding extensions to Python.
pip, which enables you to install and manage certain Python packages.
wheel, which enables you to manage Python compressed packages in the wheel (.whl) format.
Install the dependency packages First.
or direct from command prompt.
pip3 install --upgrade tensorflow
for CPU version only for TensorFlow.
pip3 install --upgrade tensorflow-gpu
for GPU version of TensorFlow