After having try many times and after searching a lot, I still don't manage to use opencv-python. Actually, import cv2 works for me, but when I want to make this file working, I got this message
Importing the multiarray numpy extension module failed
Do you have an idea of what is going on ?
In Python, OpenCV images are using the same data representation as Numpy arrays. It's quite frequent to use numpy logic on OpenCV images and vice versa.
So first thing to check is that you have numpy installed.
Assuming you have numpy installed, maybe you mixed pip and conda commands to install opencv and numpy ? It's generally something to avoid unless you really know what you are doing.
You can run pip list and conda list to have a quick overview of installed packages.
Using pip only is good enough in most cases, a lot of prebuild python wheels for Windows are available on pip, including opencv-python and numpy.
After cleaning conda installed packages, try to run :
pip install --upgrade --force-reinstall numpy to make a clean numpy install.
Related
What's the difference between
pip install numpy
and
pip install --upgrade numpy.
When I tried to use the first one to install the NumPy module in Python 3.5.2, it wasn't recognised, but when I used the second, there were no problems.
Well, the first expression is used to install a new package, numpy in this case, at the last available version (if not specified)
If you want install a particular version, for example the 1.12.0b1, you can use the following command:
pip install numpy==1.12.0b1
Finally, the --upgrade or -U param, upgrades all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.
upgrade-strategy is another parameter that you can find in the relative doc.
Since you don't have added information about errors, is difficult understand what is the real problem. I mean, the expression it wasn't recognised and there were no problems are not very clear. I suggest you to edit you question with some information.
Anyway, I suppose that you have already installed numpy on your pc, maybe in some past attempt. To verify this run the command:
pip freeze
and check if there is numpy in the installed package list.
If yes, I think that this is the reason because pip install numpy doesn't work and instead pip install --upgrade numpy yes. Basically you are not installing numpy but upgrading it, because is already installed.
Let me know.
First expression just verify if module installed. The installation will stop if module has outdated version.
Second expression will install last released or upgrade already installed package to last released version.
More info you can get from the docs
I am having a strange issue installing numpy or nltk python-modules in my windows-7 machine. I have successfully installed Python 2.7.12 but I get this error when I type pip install numpy as in this screenshot. I have also included the directory of pip.exe in the PATH. Any help would be appreciated.Thank you :)
Installing such these things in windows are sometime difficult, specially for someone new to python packages(also for some experts!)
Try to use Anaconda for windows: https://www.continuum.io/downloads#_windows
This install a python for you and many requirement packages(e.g Numpy, Scipy, Scikit and many more)
You can use older version of Anaconda, for python2.x if you want strictly python2.x
An alternative way is to download Numpy from github and then install it as a python package, that contain setup.py file
python setup.py install
Or you can download Numpy wheel package, then install it localy with pip
I'll preface by saying I'm a programming n00b by stack standards. I have experience with data analysis and scripting -- this is what I do professionally at a financial firm -- but I have no idea what I'm doing on the back end.
I'm trying to start using pandas and python --- moving away from matlab/vba but I can't figure out how to install the pandas library.
When I try to import pandas I get an error that numpy module is not present. I tried to install ezsetup / pip (no idea what this is btw)... and I have no idea where to enter this command$ python get-pip.py
Sometimes when I try to import pandas I get an error cannot import name table hashable
I have no idea what any of this means and I am not getting anywhere.
Update
Ok I installed anaconda and it seems to be allowing me to import numpy and pandas directly from the console. That being said when I try to write a basic time series and plot it using pandas syntax, i get an error that "series is not defined" as such I'm not sure if it is actually working
In [1]: import matplotlib.pyplot as plt
In [2]: ts = Series(randn(1000), index=date_range('1/1/2000', periods=1000))
In [3]: ts = ts.cumsum()
In [4]: ts.plot()
The best resource for third-party modules for Windows is Christoph Gohlke's Python Extension Packages for Windows repository. Each module is available as a self-extracting .exe installer, for use with the python.org version of Python - make sure you get the correct installer for your version and architecture.
While NumPy does not require any other packages, pandas does, so make sure you get them all. The installation order is not important.
The advantages of this resource over a distribution like Anaconda or Enthought is that Dr. Gohlke keeps the packages very up to date, allowing you to run the latest versions of the modules. Additionally, nearly all of the modules have multiple Python versions, while some of the other distributions are only based on Python 2.7.
The disadvantage is that you need to install each package individually, and there is no package manager for handling dependencies.
Best to use a pre-packaged solution, Anaconda or Enthought particularly with windows
Try this: It should work.
Go to the location where you have Python (C:\Python34)
Run the blow command:
python -m pip install pandas
NUMPY installed automatically after my Pandas installation.
I had the same headaches and the solution I finally found was to install python xy. This seems to include every package I have ever dreamed of using, and weeks of frustration evaporated almost instantly (related to pandas and many others. It's a great collection of everything you will need. It includes most all of the libraries mentioned above)
While YMMV, Enthought's Canopy caused issue after issue after issue for my installation. I advise to steer clear.
First upgrade pip version using command python -m pip install --upgrade pip after that just do pip install pandas
Note : - For pandas python-dateutil, numpy, setuptools and pytz module required.
To install pandas for Python 3, you may need to use the python-pandas package.
While NumPy does not require any other packages, pandas does, so make sure you get them all. The installation order is not important. ... The disadvantage is that you need to install each package individually, and there is no package manager for handling dependencies.
To Install numpy pip install numpy
To install pandas pip install pandas
I have a requirements.txt file like this:
numpy
matplotlib
When I try pip install -r requirements.txt inside a new virtualvenv, I get this:
REQUIRED DEPENDENCIES
numpy: no
* You must install numpy 1.1 or later to build
* matplotlib.
If I install numpy first and matplotlib after, it works. However I'd like to keep using pip install -r requirements.txt. Is it possible?
Matplotlib and pip don't seem to play together very well. So I don't think it is possible in this case.
pip first downloads a package listed in your requirements file and than runs setup.py, but it doesn't really install it (I'm not quite sure about the internals of pip). After all packages are prepared in this way, they are installed.
The problem is, that matplotlib checks if numpy is installed in its setup.py (the check itself is defined in setupext.py). So at the moment the check is performed, numpy is not installed and the matplotlib setup.py exits with the error message you received (This may not be a bug, as it may require numpy to build).
This was once addressed in pip issue #24 and issue #25. The issues are closed but give some more details.
What I am doing up to now is to first install numpy and than install all packages from my requirements file.
Update 12/2012
There is a new open pip issue which deals with this problem.
Update 04/2013
The issue is closed as WONTFIX
It's a known problem of the library and it's currently being discussed as a Matplotlib enhancement proposal: https://github.com/matplotlib/matplotlib/wiki/MEP11.
Until it's fixed the only solution I can imagine is repackaging the library to remove the numpy check.
Yes. "requirements.txt" is just a flat file from which pip can use to install packages. In that file, you can change the version of the dependencies. For example, it looks like you need at least 1.1, so try changing the line with 'numpy' to be:
numpy==1.1
Or, you can use >= like this:
numpy>=1.1
This may be what's holding you up. But, AFAIK, matplotlib should have a dependency on numpy already. Seems like that may need to be fixed.
See also this How to pip install a package with min and max version range?
and
In setup.py or pip requirements file, how to control order of installing package dependencies?
After playing with pip lately i realized that requirements file should be rearranged manually, preferably while generating it.
In simple case (i.e. just numpy and matplotlib requires ordering), you can just reverse requrements file: pip freeze | sort -r
I've just gotten used to invoking a script to repeatably set up my virtualenv; it involves two requirements file: one with only numpy, and a second one with everything else.
It's not a terrible thing to get used to, since pip will try to do 'all or nothing' when you install via a requirements file. This way, you can stage the installation so dependencies are installed first.
I made it work in virtualenv inside an iPython notebook!
I have
ipython==2.2.0
numpy==1.8.2
matplotlib==1.4.2
It works in an iPython notebook with
%matplotlib inline
from pylab import *
plot([1,2,3])
It does not work in an iPython console, though, but I am perfectly happy to do my graphing in the notebook!
At one point I was able to trick it into working from the console by installing some thing in the virtualenv, but other things only in the global namespace, but I forgot how I did it. I just kept installing and uninstalling things.
How can I install numpy in virtualenv...
easy_install numpy is throwing error.. I can not use the binary installer because this would install numpy in the python main installation and not in virtualenv..
Thanks
Another (not so great) solution is to get the installer, install it into your default Python directory, then copy it over to your virtualenv manually.
Long version
Go here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Install it.
Find it in your python installation (probably at C:\Python27\Lib\site_packages\numpy, or similar
Copy the numpy directory over to $virtual_env\Lib\sites_packages\numpy.
Worked for me, but it's not elegant. I think there are also exe installers on numpy's site, but I find it's easier to just go to the one above when I need things than to poke around on various other sites.
You cannot use easy_install directly for fairly technical reasons I would rather not get into. There is a solution, albeit not optimal: once in the virtual environment, go into numpy sources, and run:
python setupegg.py install
The key point is using setupegg.py instead of setup.py.