I have been trying to download tensorflow, and numpy so that they will work when I run them in python 3.5 idle ( the newest model that tensorflow seems to work with). I have both python 3.6 and 3.5 downloaded and I can't seem to make anything that I download( numpy so far) apply to anything but 3.6. I'm not sure if this has something to do with the path that I am calling them through command line, but I was wondering if there was an answer to this situation.
1] Using pip package manager
Use pip to install numpy for you : pip install numpy
If you do not have pip you can install it by following command : python get-pip.py
Use pip to install tensorflow for you: pip install tensorflow
2] Using Anaconda or Miniconda (RECOMMENDED)
Install Anaconda or Miniconda
conda is the package manager for Anaconda and Miniconda
Open the Conda prompt
Anaconda comes with numpy package so no need to explicitly install numpy
In case if you have downloaded Miniconda then you have to install numpy I guess. Run the following command to install numpy : conda install numpy
Run the following command to install tensorflow :conda install -c conda-forge tensorflow or simply conda install tensorflow
Anaconda also comes with it's own pip. You can use Anaconda's pip to install tensorflow by running pip install tensorflow
===========================================================================
By any chance if you get an error in the terminal saying that "command" is not recognized as an internal or external command which means you have not specified the absolute path of pip or python or conda
One solution to the above error can be to add the path of python, pip and anaconda as an environmental variable if you are on windows
If you are on Linux you can add the path of python, pip and anaconda to the PATH variable by export PATH=$PATH:/path/to/dir
Related
I'm following the instructions from https://www.tensorflow.org/install/pip#python-version-support to install tensorflow. I've used tensorflow before but for some reason, it has just stopped working. I'm using VS Code.
First, I check that pip and python are compatible:
python3 --version
python3 -m pip --version
I have Python 3.10.8, with pip 22.3.1 so it should be compatible. Then, I create a conda environment and activate it:
conda create --name tf python=3.9
conda activate tf
However, now when I try
pip install tensorflow
I get the error
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
How can I fix this? I also tried things in the past like installing tensorflow through Conda, but I get errors when importing tensorflow there.
Could you please try again by opening anaconda cmd propmt and run below code:
conda create --name tf_new python=3.10
conda activate tf_new
then install tensorflow using:
pip install tensorflow
Now open the VS code by selecting the same created VirEnv tf_new from Anaconda navigator.
In VScode, Open a new jupyter notebook file and run the below code by selecting the tf_new (Conda VirEnv) in kernel(from top right) .
import tensorflow as tf
tf.__version__
Output:
'2.11.0'
Last night, I made a virtual environment and the only installs I made were as follows:
conda install jupyter
conda install notebook
pip install transformers
And I was able to run huggingface transformers perfectly, but today I reactivate my conda virtual environment and I'm met with this puzzling error:
And this is the runtime error
I even tried making a new virtual environment with the same depencies and today I got these errors upon performing pip install transformers
And this in jupyter notebook
HuggingFace Transformers need to be installed in conjunction to either Tensorflow or Pytorch. From the HuggingFace installation instructions:
First you need to install one of, or both, TensorFlow 2.0 and PyTorch.
So you should choose which machine learning platform you like more and install that too in your virtual environment.
For Tensorflow either pip install tensorflow or pip install tensorflow-gpu and for Pytorch pip install torch torchvision
For example, in a fresh environment, the following instructions should make your errors disappear (I'm assuming you have a GPU):
conda install jupyter
conda install notebook
pip install tensorflow-gpu
pip install transformers
To get tensorflow working on an M1 mac I installed anaconda navigator, and then followed these instructions:
install miniforge, and then
tensorflow-deps
tensorflow-macos
tensorflow-metal
Installing these packages did not give any errors, but when I try to launch a Jupyter notebook from the Anaconda Navigator interface I get this error
ImportError: dlopen(/Users/../miniforge3/envs/macos-tensorflow64/lib/python3.8/site-packages/zmq/backend/cython/_device.cpython-38-darwin.so, 0x0002): tried: '/Users/../miniforge3/envs/macos-tensorflow64/lib/python3.8/site-packages/zmq/backend/cython/_device.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
It seems that _device.cpython-38-darwin.so is not ready for M1 ? Is this a bug?
How can I get tensorflow working on the M1 mac? (with a jupyter notebook). Note: I did get Jupyter notebook working with python in general, just not with tensorflow).
It seems you have installed miniforge 'x86_64' file whereas you need 'arm64' as shown in the ImportError message.
Please try again by installing miniconda macOS (Miniconda3 macOS Apple M1 64-bit bash) package and run below code step by step in the terminal to access the tensorflow with jupyter notebook:
Download the miniconda package, open the terminal and cd to the
download directory to access the miniconda.sh file
cd downloads
bash <the_downloaded_package.sh> - agree(yes) to the License terms and confirm the miniconda installation directory.
cd to the installed miniconda directory and create conda virtual environment for tensorflow
conda create --name tf python=3.9
conda activate tf
Now install TensorFlow using
pip install --upgrade pip
python -m pip install tensorflow #or
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
To verify if tensorflow installed, type:
python (enter)
>>import tensorflow as tf
>>tf.__version__
Install and open the jupyter notebook.
conda install jupyter
jupyter notebook
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.
I have been trying to update tensorflow from 1.2.1 to 1.3.
I did the following on my terminal:
pip3 install tensorflow --upgrade
After this, I tried checking the version
python3 -c 'import tensorflow as tf; print(tf.__version__)'
This outputs 1.2.1 but not 1.3.0
All this had been done in an anaconda environment.
Operating system: macOS Sierra
I would like to know how one can perform this update.
Thank you
The solution that I found was to install pip inside the conda environment and use that instance of pip to install the packages. Please refer here
The reason I got the above error was that the python3 and pip3 paths were different.
This became evident when I ran the below commands inside the conda environment.
which python3
/Users/SMBP/anaconda/envs/tensorflow/bin/python3
which pip3
/usr/local/bin/pip3
Also, I think it is better to use virtualenv and virtualenvwrapper if you wish to work with tensorflow as it is the recommended way.