I am trying to install the OpenCV-python on my mac and i have used the following:
$pip install opencv-python
which gave me the following error:
$pip install opencv-python
Collecting opencv-python
Using cached opencv_python-3.4.0.12-cp27-cp27m macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting numpy>=1.11.1 (from opencv-python)
Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: numpy, opencv-python
Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Then i did try the pip install --upgrade matplotlib which didnot change anything. It just show me:
matplotlib 2.2.2 requires backports.functools-lru-cache, which is not installed.
matplotlib 2.2.2 has requirement numpy>=1.7.1, but you'll have numpy 1.8.0rc1 which is incompatible.
As I found many ways to install the openCV-python in the internet like:
https://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/
and I installed on my other mac but i got import cv2 problem alot in my codes.
I will be more than happy if anyone have a good solution or recommendation to install the openCV-python.
Thanks
In summary, macOS comes with the Python preinstalled and you should not mess with the packages installed as some system utilities depend on them.
https://docs.python.org/3.7/using/mac.html
The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.
You should take a look on either venv or virtualenv.
You can read this answer: https://stackoverflow.com/a/41972262/4796844 that will get you through the basics.
In a nutshell, to solve your problem:
$ python3 -m venv ./project-name
$ . ./project-name/bin/activate
$ pip install opencv-python
And to leave the virtual environment, simply:
$ deactivate
Related
I am using python 3.6.0 within a venv. I would like to "pip install" matplotlib==2.0.0, however when I do this, pip seems to automatically grab the newest versions of all other required supporting packages for matplotlib. i.e. cycler 0.11.0, pyparsing==3.0.7, etc. These latest supporting package versions do not seem to work with the older version of matplotlib and it throws errors when attempting to import matplotlib.
How do I install matplotlib without pip attempting to install all its supporting packages automatically?
My current temporary solution is to go back and manually install each package before installing matplotlib but I'm sure I will run into this issue again so would like to find a better solution.
Pip has a built-in feature:
pip install matplotlib --no-dependencies
To exclude specific, you can put it in requirements file and pass it:
pip install --no-deps -r requirements.txt
I am new to Python and terminal prompts/installs and I keep running into installation errors when trying to install modules like Pandas.
I have successfully installed "pip install pandas"
I am unable to install this with pip3 however.
Collecting pandas
Could not find a version that satisfies the requirement pandas (from versions: )
No matching distribution found for pandas
I have pip3 installed and python3(this comes with mac os).
I do not understand the conflict between the versions. If I install using pip, its only compatible with python2?
Why wouldnt I be able to install it using pip3 (see error above)?
Am I somehow installing in the wrong directories or not making the correct distinction for python3 and pip3 version compatibility? Thanks for any insight.
As already said in the comments, pip installs modules for python2. Also, you can't run pandas as a command on the shell.
pip3 install pandas works for me, on python3 (v3.7.4), which was installed directly from a Mac installer package on the python website. No 'environment configuration' was required.
>pip3 install pandas
Collecting pandas
Downloading https://files.pythonhosted.org/packages/ab/ba/f97030b7e8ec0a981abdca173de4e727b3a7b4ed5dba492f362ba87d59a2/pandas-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl (9.8MB)
100% |████████████████████████████████| 9.8MB 2.8MB/s
If you've installed python3 using some different method, then you may need to install packages differently or configure your python installation in some way.
I'm learning python and want this code to work.
import pandas
df =pandas.DataFrame([[2,4,6],[10,20,30]])
print(df)
This is what I get:
File "C:\Users\User\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I'm using pycharm with anaconda environment. Hopefully I've set the environment and interpreter up right. It says I have numpy version 1.16.2 installed, however it won't let me upgrade to version 1.17.0
Tried installing, uninstalling and upgrading through packages and terminal and upgraded pip. This is what I get:
Installing collected packages: numpy
Found existing installation: numpy 1.16.4
Uninstalling numpy-1.16.4:
Successfully uninstalled numpy-1.16.4
Successfully installed numpy-1.17.0
WARNING: You are using pip version 19.1.1, however version 19.2.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\User\Documents\Python>python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl (1.4MB)
|████████████████████████████████| 1.4MB 114kB/s
Installing collected packages: pip
Found existing installation: pip 19.1.1
Uninstalling pip-19.1.1:
Successfully uninstalled pip-19.1.1
Successfully installed pip-19.2.1
I'm very new to all this and probably doing something wrong, someone please help.
enter image description here
I would advise you to try and use the Anaconda GUI Navigator, available through the standard download of Anaconda Software Bundle.
You can easily manipulate virtual environments and install/uninstall different packages, using the self-explanatory GUI. I found it very simple and a good way to start using Anaconda and Python:
Today I decided to install python and the scipy stack manually, instead of using Anaconda (or Canopy) as I had previously done. I use homebrew on my mac and have python2 and python3 (2.7 and 3.6) installed via homebrew. But reading through the documentation, there are multiple ways to install the scipy stack and I want to know what the differences are. I have tested they independently and they all work.
From the Homebrew documentation:
python2 -m pip install numpy scipy matplotlib
python3 -m pip install numpy scipy matplotlib
These are the same two commands that the Matplotlib installation docuentation lists for how to install matplotlib through homebrew. Why does this use pip (the system Python 2.7.x's pip) instead of pip2 and pip3 respectively? Is it because you call python2/python3 first?
However, the SciPy documentation for installing these modules when using homebrew is different:
brew tap homebrew/science && brew install numpy scipy matplotlib
(NOTE: the matplotlib formula is located in the homebrew/science repository, which is why you need to use brew tap.)
Finally, from the command line readout when installing python2 and python3 via homebrew:
pip2 install numpy scipy matplotlib
pip3 install numpy scipy matplotlib
which are based on the following readouts:
Pip and setuptools have been installed. To update them
pip2 install --upgrade pip setuptools
You can install Python packages with
pip2 install <package>
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python.html
...
Pip, setuptools, and wheel have been installed. To update them
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: https://docs.brew.sh/Homebrew-and-Python.html
So between four sources of documentation, there are three different ways to install scipy when using homebrew and they all work; but how is each different and should one be preferred?
From what I can tell, the first and third methods, which both invoke pip (pip2/pip3), are functionally equivalent - both invoke Homebrew's Python X.X.X's pip - but one implicitly, the other explicitly. I assume this means both methods install the pre-built binary packages from pip in the form of wheels. For the second method, I think it installs homebrew's own formulae for these packages (i.e. maintained separately by homebrew in it's repository).
If this is true, then I assume one should use the second method if you are using a version of python which is maintained by homebrew (i.e. installed via brew install python or python3). My reasoning is that if you later decide to install another formula via homebrew that has any of the scipy stack as a dependency, it will install those modules again from homebrew's repository if you installed them using pip previously.
As mentioned, I am not sure if my understanding is correct and I have not been able to find any answers, so any insights or confirmations would be appreciated.
Your analysis seems correct: variants 1 and 3 will install numpy/scipy from the python package index (PyPI) and will use pre-built wheels (if available for your platform, which they most likely are).
Variant 2 installs the brew formula.
As mentioned by #Evhz, the conda packages for numpy and scipy use the Intel Math Kernel library, which can provide significant speedups (not just on Intel processors) versus the packages installed from PyPI or brew, both of which are linked against OpenBLAS.
Concerning which method to prefer: it's not entirely straightforward.
Yes, on the surface, using brew to manage both the python interpreter and the python packages would seem consistent.
However, homebrew only provides formulae for a handful of python packages, so you'll end up needing to mix with pip in any case.
If you want performance, you go with conda, which will be managing both the interpreter and python packages.
However, also anaconda / conda-forge still have some catching up to do with PyPI, so you'll likely need to mix with pip again.
In the end, there is no perfect solution but as long as you knowingly decide for one, you're unlikely to run into issues.
Whenever I try to upgrade matplotlib using pip install matplotlib --upgrade I get the following
"setuptools must be installed to install from a source distribution"
setuptools is installed and up to date, so I'm lost.
EDIT:
If this adds any context, it started happening after I upgraded distribute
EDIT:
I solved the problem by uninstalling and reinstalling setuptools