aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.42k stars 2.44k forks source link

setup.py does not recognize opencv2 of Anaconda #25

Open clockwiser opened 7 years ago

clockwiser commented 7 years ago

When run the setup, error happens. opencv is installed on Anaconda. Is it possible to install imgaug on Anaconda? ... Processing ./dist/imgaug-0.2.0.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-K5MRPU-build/setup.py", line 6, in raise Exception("Could not find package 'cv2' (OpenCV). It cannot be automatically installed, so you will have to manually install it.") Exception: Could not find package 'cv2' (OpenCV). It cannot be automatically installed, so you will have to manually install it.

aleju commented 7 years ago

The check does nothing more than trying to import cv2, which is required for the library. I don't use Anaconda, but all guides that I see look like it also should have a cv2 package if opencv is installed, i.e. you should be able to do import cv2 without an error. Are you sure it is installed correctly?

clockwiser commented 7 years ago

Anaconda has opencv and import cv2 has no problem. Only when installing imgaug, error happens.

clockwiser commented 7 years ago

Tried all commands described as below, same errors.

To install, simply use sudo pip install imgaug. That version might be outdated though. To always get the newest version directly from github use sudo pip install git+https://github.com/aleju/imgaug. Alternatively, you can download the repository via git clone https://github.com/aleju/imgaug and install by using python setup.py sdist && sudo pip install dist/imgaug-0.2.0.tar.gz.

clockwiser commented 7 years ago

A closed issue #12 says:

You can now simply install via sudo pip install imgaug or sudo pip install git+https://github.com/aleju/imgaug.

Looks ok with Anaconda?

aleju commented 7 years ago

If importing cv2 works in your python scripts but not during the installation, it might be that your pip command does not use your anaconda installation of python (but instead a different one that doesn't have opencv). The help threads that I can find sound like which pip should return something like /home/username/anaconda/bin.

clockwiser commented 7 years ago

Solved.

  1. Find the Anaconda envirenment name conda info --envs

  2. Activate anaconda environment. source activate enviroment-name

  3. Install imgaug using pip. pip install git+https://github.com/aleju/imgaug

Note: don't use 'sudo pip', which causes the error.

clockwiser commented 7 years ago
  1. install opencv2 to anaconda conda install -c menpo opencv=2.4.11

  2. pip install git+https://github.com/aleju/imgaug

minlee077 commented 5 years ago

Solved.

  1. Find the Anaconda envirenment name conda info --envs
  2. Activate anaconda environment. source activate enviroment-name
  3. Install imgaug using pip. pip install git+https://github.com/aleju/imgaug

Note: don't use 'sudo pip', which causes the error.

Additionally, if you use ipython or jupyter notebook environment, you should install the environment in conda virtual environment.

conda install ipython jupyter

then running on the environment. If you skip this process, jupyter or ipython would running on your global environment so that it can't import the package.

pissw2016 commented 5 years ago

from conda-forge conda install -c conda-forge imgaug then it will install by anaconda