pip3 not found in Tensorflow environment: "-bash: pip3: command not found" - python-3.x

I'm following instructions to create a Tensorflow environment for a Machine Learning course, with python 3.5, ipython and jupyter.
I created a Tenserflow environment with python 3.5 using conda create -n tensorflow python=3.5. That worked.
Then I ran conda install -c conda-forge tensorflow. That also worked.
Then I installed ipython with conda install ipython, which also worked fine.
However, when I ran pip3 install jupyter, I got error message bash: pip3: command not found.
I found a few posts about variations on pip3 problems and (within the Tensorflow environment):
When I type pip --version, it tells me I have version 8.1.2
When I try locate pip3, I get WARNING: The locate database (/var/db/locate.database) does not exist
I tried using pip-3.2 as recommended in one of the other questions' solutions (which worked for that OP), and I get the same command not found error message.
I'm using OS X 10.8.5

pip is different from pip3. So you might need to install it if it can't be found. If it is installed run this:
sudo updatedb
this will update the locate function.
if you're using conda why do you want to install it with pip anyways?
Jupyter is the new version of ipython. running conda install ipython installs ipython (now jupyter).

Related

Unable to Install Jupyter due to legacy-install-error with psutil package

I was previously running into environment inconsistencies after downloading tensorflow with pip in a conda environment, and after several hours of frustration, decided deleting anaconda/miniconda and python and starting from scratch would be my best option to get python working again (The inconsistencies were causing a plethora of issues with loading other modules like numpy, etc).
After downloading Python version 3.9.10 directly from https://www.python.org/downloads/macos/, I wanted to see if I could start using Python again in a Jupyter notebook in VS Code. When I try to run a simple print('hello world') in a python chunk I (unsurprisingly) get the following error:
Jupyter cannot be started. Error attempting to locate jupyter: Running cells with 'Python 3.9.10 64-bit' requires notebook package.
Run the following command to install 'jupyter and notebook' into the Python environment.
Command: 'python -m pip install jupyter notebook -U'
I was pretty much expecting this error, since I knew I had deleted all packages when deleting Anaconda and Python.
However, when I try running python -m pip install jupyter notebook -U in the terminal I ultimately get the following error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> psutil
note: This is an issue with the package mentioned above, not pip.
Any help or insight is greatly appreciated! I am on MacOS (M1) if that is useful information.
The problem seems to be with the python3 distribution that comes with MacOSX Command Line Tools. Well, at least that same error was gone after following these steps.
So, to fix the problem I installed python3.9 (I presume you can change 3.9 to your desired version, e.g. 3.8 or 3.10) using Homebrew.
Install Homebrew (to check if it's installed already just type brew --version in the terminal):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install python3.9
brew install python#3.9
Create your virtual environment
python3.9 -m venv myvenv
Activate the virtual environment with source myvenv/bin/activate
Finally, install Jupyter using
(myvenv) pip install jupyter notebook
I have the same problem when installing the Jupyter notebook on MacOS 12.5 M2 chip. It turns out that the error is caused by not having GCC on my mac to run the wheel for installing the psutil package because for some reason I removed my XCode from my Mac. So I installed XCode from AppStore and opened XCode after the installation to agree to its terms and conditions. After Xcode went through the setup process I tried pip install jupyter again and it worked well.
In my case, I just opened the XCode, accept the terms and the installation proposed, and tried to install the jupyter again and it worked!
It seems to be very particular about the version of python installed. I set up a fresh installation on a new box this morning and put 3.11 on there. pip install jupyterlabs gave me the same error as you got. I then uninstalled python and installed an earlier version, and now it works.
PS the older version that worked for me is 3.10.8

Unable to install tensorflow using conda with python 3.8

Recently, I upgraded to Anaconda3 2020.07 which uses python 3.8. In past versions of anaconda, tensorflow was installed successfully. Tensorflow failed to be installed successfully in this version.
I ran the command below;
conda install tensorflow-gpu
The error message that I received is shown below;
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- tensorflow-gpu -> python[version='3.5.*|3.6.*|3.7.*|>=3.7,<3.8.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0|>=2.7,<2.8.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
The following specifications were found to be incompatible with your CUDA driver:
- feature:/win-64::__cuda==11.0=0
Your installed CUDA driver is: 11.0
Is there a conda command with the right parameters to get tensorflow installed successfully?
UPDATE:
TF is now compatible with Python 3.8
Tensorflow is not compatible with Python 3.8. See https://www.tensorflow.org/install/pip
You need to downgrade your python version :
conda install python=3.7
Create an environment with python 3.7 and then activate it:
conda create -n p37env python=3.7
conda activate p37env
And install tensorflow.
This worked for me, and found out the answer from the Anaconda user guide (under how to use a different python version: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python )
From the requirement page:
Python 3.8 support requires TensorFlow 2.2 or later.
So there is a verison of Tensorflow compatible with python 3.8.
The problem is that TensorFlow 2.2.0 is not available through conda on Windows, this should be the reason why you get PackagesNotFoundError when running
conda install tensorflow=2.2
EDIT 15/03/21
Tensorflow 2.3.0 is compatible with Windows
i think we have two options here
pip install tensorflow
or we can use another env of anaconda such as like this below
conda create -n tf tensorflow pydotplus jupyter
conda activate tf
Actually you can directly use pip inside anaconda prompt, after I tested it, I found the conda is capable with pypi, first run the anaconda prompt with administrator permission (in windows), then enter "conda update --all" to make sure all the packages are latest, finally enter "pip install tensorflow" to install (the new version of tensorflow already includes tensorflow-gpu).
Then using VS code to open an ipynb and run
import tensorflow as tf
tf.test.gpu_device_name()
everything looks good.
For more info please refer to Anaconda official docs: https://docs.anaconda.com/anaconda/ .
Latest development for tensorflow installation on anaconda.
https://anaconda.org/anaconda/tensorflow
https://anaconda.org/anaconda/tensorflow-gpu
9 days ago, Anaconda uploaded a new tensorflow v2.3 package. Anaconda3 2020.07 (uses python v3.8) users can easily upgrade to tensorflow v2.3 with the following commands;
conda install -c anaconda tensorflow
conda install -c anaconda tensorflow-gpu
I have personally tested that the installation worked successfully.
The other answers for this question have now become obsolete.
Expanding upon William's answer here with more explicit instructions and caveats. Pip is the recommended way to install latest version of tensorflow as per tensorflow's installation instructions -- "While the TensorFlow provided pip package is recommended, a community-supported Anaconda package is available."
Here is the code that uses pip to do the installation in a Conda environment:
conda create -n env_name python=3.8
conda activate env_name
conda install pandas scikit-learn matplotlib notebook ##installing usual Data Science packages that does include numpy and scipy
pip install tensorflow
python -c "import tensorflow as tf;print(tf.__version__)" ##checks tf version
In general, we should be careful while mixing two package managers (conda and pip). So, it is suggested that:
Only after conda has been used to install as many packages as possible
should pip be used to install any remaining software. If modifications
are needed to the environment, it is best to create a new environment
rather than running conda after pip.
For an example, if we would like to install seaborn in the just created env_name environment, we should:
conda create --name cloned_env --clone env_name
conda activate cloned_env
conda install seaborn
Once we check the cloned_env environment is working fine, we can delete the env_name environment.
I was running into the same issue in conda prompt for Python 3.8.5 and fixed it using a Python wheel instead. Here are the steps:
Open conda prompt and install pip if you don't have it already: python -m pip install --upgrade pip
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.4.0-cp38-cp38-win_amd64.whl
Note: If you need a CPU specific tensorflow, use this wheel: https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.4.0-cp38-cp38-win_amd64.whl
I just downgraded python to 3.7 as tf is not avialable to 3.8 version also I cannot use virtualenv for code that's why
The only working answer for me is:
conda install -c conda-forge tensorflow
It appears that tensorflow 2.5 on GPU has issues with spyder. So, I made new environment and installed tensorflow gpu as suggested by anaconda. Now I have to use either prompt or jupyter . At least it works
For macos users I suggest create an environment with python 3.7 and install tensorflow there.
You can run these commands too:
conda create -n new_env_name python=3.7
conda activate new_env_name
I had a similar problem in Anaconda Spyder. Here was my solution (In the Anaconda Console):
conda install pip
pip install tensorflow ==2.2.0

conda_env package is not available upon downgrading Python version to 3.6

I'm trying to create a Docker image with Conda and Python 3.6 installed. I have installed Anaconda 3 with the default Python 3.7. Then I used the following command to downgrade to Python 3.6:
conda install -y python=3.6
This results in Python 3.6 successfully installing, but when I subsequently execute conda --version, it gives me the error
'conda' module not found
I found that under python3.6/site-packages folder there are no Conda-related packages and instead all these packages are found under python3.7/site-packages.
It used to work before. Is there a way to get conda packaged under python3.6 folder?
Srikanth,
You should always try creating a new environment when you are working with some old version of any library.
conda create -n myenv python=3.4
If you want to install specific packages in this environment, you can use
conda install -n myenv tensorflow
Refer to this documentation for more information:
docs.conda.io

Python 3.5.2 Windows x86-64 web-based, but installer not installing pip

I am trying to install TensorFlow. The installation instruction for Windows (https://www.tensorflow.org/install/install_windows) have as first step to install Python 3.5.2. And I'm doing the 'TensorFlow with CPU support only'.
Python was successfully installed in my computer as I can run it via the Start menu.
However, when I try to do the 2nd step of the installation instructions in order to install TensorFlow, this step says to:
To install TensorFlow, start a terminal. Then issue the appropriate pip3 install command in that terminal. To install the CPU-only version of TensorFlow, enter the following command:
C:\> pip3 install --upgrade tensorflow
But I'm getting an error when I perform the above statement, the error is
'pip' is not recognized as an internal or external command, oprable program or batch file.
I looked at several postings in StackOverflow and tried the commands provided in one of the postings, but I would get the same type of error.
So, how is 'pip3' installed? from what I read, it is supposed to be installed together with the installation, but obviously that did not happen.
How do I install it? I need to install TensorFlow and it seems that it needs to be done via the pip3 installation tool.
Thank you in advance for your help!
Either set the system environment path variable to include the python 3.5.x path in it, or just cd into the correct python folder to run pip3 from there.
The folder in windows 10 should be something like this:
C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python35\Scripts
Open the terminal, cd to that path (change YOUR_USERNAME to the correct user) and then just run the following command:
pip3 install --upgrade tensorflow
and if you want the gpu version:
pip3 install --upgrade tensorflow-gpu
Pip3 is already installed when you install Python, so there is no need to do anything else.

Error when executing `jupyter notebook` (No such file or directory)

When I execute jupyter notebook in my virtual environment in Arch Linux, the following error occurred.
Error executing Jupyter command 'notebook': [Errno 2] No such file or directory
My Python version is 3.6, and my Jupyter version is 4.3.0
How can I resolve this issue?
It seems to me as though the installation has messed up somehow. Try running:
# For Python 2
pip install --upgrade --force-reinstall --no-cache-dir jupyter
# For Python 3
pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
This should reinstall everything from PyPi. This should solve the problem as I think running pip install "ipython[notebook]" messed things up.
For me the issue was that the command jupyter notebook changed to jupyter-notebook after installation.
If that doesn't work, try python -m notebook, and if it opens, close it, then
export PATH=$PATH:~/.local/bin/, then refresh your path by opening a new terminal, and try jupyter notebook again.
And finally, if that doesn't work, take a look at vim /usr/local/bin/jupyter-notebook, vim /usr/local/bin/jupyter, vim /usr/local/bin/jupyter-lab (if you have JupyterLab) and edit the #!python version at the top of the file to match the version of python you are trying to use. As an example, I installed Python 3.8.2 on my mac, but those files still had the path to the 3.6 version, so I edited it to #!/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
Try this command: python -m IPython notebook
Credits to the GitHub user Milannju who provided the solution here.
This worked for me. (Python 3.6 on Ubuntu 18.04 LTS)
export PATH=$PATH:~/.local/bin/
On Ubuntu 18.10, the following command helped me out.
sudo apt-get install jupyter-notebook
Jupyter installation is not working on Mac Os
To run the jupyter notebook:-> python -m notebook
Use the command below and if you are using pip3 replace pip by pip3
pip install --upgrade --force-reinstall jupyter
This worked for me.
Since both pip and pip3.6 was installed and
pip install --upgrade --force-reinstall jupyter
was failing, so I used
pip3.6 install --upgrade --force-reinstall jupyter
and it worked for me.
Running jupyter notebook also worked after this installation.
Deactivate your virtual environment if you are currently in;
Run following commands:
python -m pip install jupyter
jupyter notebook
For me the fix was simply running pip install notebook
Somehow the original Jupiter install got borked along the way.
I'm trying to get this going on VirtualBox on Ubuntu. Finally on some other post it said to try jupyter-notebook. I tried this and it told me to do sudo apt-get jupyter-notebook and that installed a bunch of stuff. Now if I type command jupyter-notebook, it works.
If you are on Fedora installing python3-notebook resolved my problem.
# dnf install python3-notebook

Resources