Finding and uninstalling PIL on Mac - macos

I want to install Pillow and have read in many places this only works if PIL is removed.
Somewhere I have PIL installed but I am unable to find it or remember how it was installed. I'm pretty much a ctrl+c and ctrl+v guy when it comes to installing things through terminal, so I imagine I had some trouble installing it in the first place.
I have tried
pip uninstall PIL
easy_install uninstall PIL
brew uninstall PIL
and run out of ideas. I can't even find any file with name "PIL" with spotlight.
Just want to find a way to get rid of PIL and install Pillow so I can add text to a few hundred images.
Running python 2.7 on El Capitan

To find where PIL is located on your machine, use Python to import it and have it print out its location:
$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> PIL.__file__
On my system, this gives:
'/Library/Python/2.7/site-packages/PIL/__init__.pyc'
From this you can see where your site-packages directory is located. Now exit python, go into /Library/Python/2.7/site-packages/ (your exact path may differ from mine) and delete the folder PIL. That should get rid of it.
cd /Library/Python/2.7/site-packages/
sudo rm -rf PIL

Related

pip3 packages are being installed in ~/.local folder

I recently upgraded to ubuntu 20.04 LTS. As python3.8 was preinstalled, I installed pip using the command sudo apt install python3-pip , and I started installing python3 libraries. All the libraries I install are being installed into ~/.local/lib/Python3.8/site-packages folder. If I remember correctly, these packages should be installed into /usr/local/lib/python3.8/dist-packages.
madhan#madhan:~$ pip3 show tensorflow
Name: tensorflow
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages#tensorflow.org
License: Apache 2.0
Location: /home/madhan/.local/lib/python3.8/site-packages
After the packages are installed, I get a warning saying ~/.local/bin is not included in $PATH variable.
Installing collected packages: appdirs, cachelib, pygments, cssselect, lxml, pyquery, howdoi
WARNING: The script pygmentize is installed in '/home/madhan/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script howdoi is installed in '/home/madhan/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed appdirs-1.4.4 cachelib-0.1 cssselect-1.1.0 howdoi-1.2.1 lxml-4.5.1 pygments-2.6.1 pyquery-1.4.1
even if ~/.local/bin is not included in $PATH variable, I am still able to import the packages.
madhan#madhan:~$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
Does anybody know why this is happening? How do I change the default folder to which pip3 packages are installed. Is it okay leave the packages in ~/.local folder or will it be a problem in the future?

Tensorflow Module not found on Mac

I'm using default version of Python(2.7) on Macbook Pro with High Sierra. I have installed default version of tensorflow, which is 1.9, with this command:
pip -V
>>>pip 18.0 from /usr/local/lib/python2.7/site-packages/pip-18.0-py2.7.egg/pip (python 2.7)
pip install tensorflow
pip list
>>>tensorflow 1.9.0
Then I fire up python:
python
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Then I try to import tensorflow and get this error:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
>>>
I have tried to follow the instructions multiple times with no success. I'd appreciate any help. Thanks.
When you installed tensorflow it might be associated with a different version of python. I suggest you run in virtual environments. Create a virtual environment and activate it. Then once its activated run pip install tensorflow and then try to run your code with your virtual environment still activated.
This link has a much better description of why you need virtual environments and how you install them.

How to install numpy scipy matplotlib and open cv in python 3.6 macbook pro?

I had installed Python 3.6 in my windows laptop from python.org . After that I ran cmd and did pip install numpy and pip install numpy. It installed successfully. Thereafter I ran idle(python gui) and typed import numpy and then import scipy, Both worked.
After that I got opencv3 whl file and then did pip install with it too in cmd and it imported in python.
Can anyone explain step by step in detail how to install opencv,matplotlib, scipy, and numpy in Macbook so that I can import it in the python 3 version of Macbook or can you just help me in installing in any way but with detailed explanation?
To install OpenCV without anaconda, open terminal and exec this command
pip install opencv-python
and import module in your Python by following line of code
import cv2
The simplest solution is to install Anaconda and than:
conda install opencv
If you want fewer packages installed (Anaconda comes with 200+ of them), use Miniconda and than:
conda install numpy scipy matplotlib opencv
Now :
>>> import cv2
>>> cv2
<module 'cv2' from '.../miniconda3/envs/opencv/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so'>
If this does not work, try making a new environment:
conda create -n opencv python=3.6
Answer with ENTER.
Later:
source activate opencv
The prompt should change to (opencv).
Now:
(opencv) conda install numpy scipy matplotlib opencv
STEP 1: go to anaconda website and download the anaconda with python 3.6 for mac https://www.anaconda.com/download/#macos
STEP 2: install with graphical user interface
STEP 3: open terminal and give command "conda --version" to check if anaconda was installed perfectly.
STEP 4: the give the command "conda update conda" . thos will update all the packages to recent version.
STEP 5: now again go to conda website https://anaconda.org/ and type "opencv' in the search bar.
search open cv in that box
STEP 6: click on conda forge
this one in this image
STEP 6: now do as it says in the instruction provided there ie. open TERMINAL and run one of the following :
conda install -c conda-forge opencv ( i used this one and it worked)
or:
conda install -c conda-forge/label/broken opencv
STEP 7: enter y if asked in terminal.
STEP 8: after install open new terminal and type python and then type "import cv2" . if all was error free till now then the prompt arrow will be shifted to next line.
STEP 9: enjoy coding :)

My Pip points to the wrong path and cannot install packages inside a virtualenv

I want to create a virtualenv with python3.4 and pip3 on ubuntu 14.04 but I cannot do it. I've tried in my normal ubuntu14.04LTS machine and in a new one from livecd to check it again from scratch but I cannot make it work. I've tried virtualenv (with and without virtualenvwrapper) and a lot of different commands, tools and scripts I've found around with no luck. Two days lost with this, messing with Python2.7 and specially pip different versions. Let me explain as detailed as possible to help you understand:
As you know, Ubuntu 14.04LTS comes with Python3.4 installed by default and this Python version comes with a tool called py-venv-3.4 so you don't need to use virtual-env and that's the way I'm trying now.
From the clean live-cd I try the following:
sudo apt-get update
sudo pyvenv-3.4 my env
It throws an error:
Error: Command '['/home/ubuntu/Desktop/mi_entorno/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
so I have to create it without pip to make it work.
sudo pyvenv-3.4 --clear --without-pip my_env
sudo source my_env/bin/activate
From now on, I'm inside the virtual environment.
At this point I'm good because inside the environment the python command points to the right version (3.4). First common issue solved. But the problem comes with pip. Of course as I checked "without-pip" pip3 doesn't work and I have to install it.
sudo apt-get install python3-pip
sudo pip3 --version
And the fun comes:
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
It's pointing the right version of python, but not the inner one but the outer, for no reason (Outside, pip3 is uninstalled by default!). But just to make sure this is wrong I try to install django in the environment and check it.
sudo pip3 install django
sudo python
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'django'
>>>
Great. Now I go outside the environment back to my "normal" shell:
deactivate
python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 6, 5, 'final', 0)
>>>
And django works as expected cause pip installed it outside the environment. I'm new to Python packaging dependencies and I've lost close to 20 hours with this in my last two days. Does anyone have a simple way to create a single virtual environment on ubuntu14.04 with python3.4 and pip3? I don't think I'm asking for much :(
Any help is a blessing.

Install Numpy on Mac OS X Lion 10.7

I need to install Numpy on my Mac OS X Lion 10.7. I googled a little bit, it seems like there are a lot of stuff needs to be installed. And some says I need install Xcode before I install Numpy. But the official website of Numpy doesn't give much information about installing Numpy on Mac. I really don't want to install Xcode as it would cost a lot space.
So anyone knows how to install Numpy? What's the prerequisites?
Thanks,
Lion comes with numpy installed. It should already be there:
$ python -c 'import numpy, numpy.version; print numpy, numpy.version.version'
<module 'numpy' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.py'> 1.5.1
For anyone that hits this from google, here is where I figured out how to build numpy on Mac OS.
http://www.scipy.org/Installing_SciPy/Mac_OS_X
On lion, it amounts to setting some environment variables (after Xcode is installed):
export CC=gcc-4.2
export CXX=g++-4.2
export FFLAGS=-ff2c
Then pip install numpy works just fine.
I have used a few software packages that require a fresh install of NumPy, that won't work with the built in NumPy or even with the built-in Python. The easiest way to install NumPy on the mac is to download any of these packages. This will work for most OS versions.
Python 2.7
Python 2.6
Python 2.5
Still the other answers are valid, though this is a more general answer.
This is the SourceForge page of the project.
If you do install Xcode you can get the latest and greatest open source libraries and packages. Consider using the excellent Mac Ports (http://www.macports.org) project. It is a package manager that will download source packages and their dependencies and build all the libraries and tools for you.
Installing Numpy becomes a one line command once Xcode and mac ports is installed:
sudo port install py27-numpy
The easiest way that I found was to visit http://sourceforge.net/projects/numpy/files/NumPy/, pick the folder of the latest version, and then download the .dmg file that matched my installed version of Python.
Based on this post, I found that Chris Fonnesbeck keeps a highly functional installer script for OSX 10.7 at the OSX SuperPack Github site.
Because I hapened to have all the dependencies (such as gfortran) already, I did not use his full shell script. Rather I just did
git clone --depth=1 git://github.com/fonnesbeck/ScipySuperpack.git
python -m easy_install -N -Z ScipySuperpack/*.egg
And it worked beautifully. In particular, it worked better than the .dmg files from the official numpy and scipy distributions, and better than pip install.
You can install numpy/scipy using pip, If pip is not installed on your machine, you can install it with easy_install:
sudo easy_install pip
Then install numpy:
sudo pip install numpy
A very easy route is to install Anaconda from Continuum, or Enthought's Canopy. These are python distributions that include numpy, as well as other useful scientific computing libraries
Generally, unless you have a good reason you might want to avoid trying to have to build numpy/scipy et al. yourself.
For Mac's there are two nice everything-included packages for numerical python. Enthough distribution (paid, http://www.enthought.com/) and Sagemath (free, http://www.sagemath.org/). I'm happily using Sagemath on 10.7 - it has numpy, scipy etc.

Resources