Python defaults to wrong version; can't find scipy - scipy

I am new to python, hoping to use it for scientific computation, data acquisition, etc. My ignorance is near total.
I am using a macbook pro, running OSX 10.9.5.
I first installed python 2.7, numpy, and matplotlib; can't remember where they came from. They seem to sit in /Library/Frameworks/Python.framework....
All was OK, until I realized I need scipy also. So, I installed the entire scipy stack from scipy.org, using 'sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose', after having first installed xcode and the developer tools.
This new installation is located in \opt\local\var\macports\software...
Here's the question: When I run python in a terminal, it always defaults to the original installation. scipy, in particular, cannot be found. I suppose this is a path problem, but I am out of my depth here. Can someone help?

Related

WinPython Spyder can't see spyder-kernels in virtual environment

I have installed WinPython and want to use Spyder. I use pip and virtual environments. I have followed the instructions here modular approach. Everything works just dandy until the very last instruction "Start a new IPython console (in Spyder). All packages installed in your venv environment should be available there.".
It get error Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed (>= 1.9.0 and < 1.10.0). Without this module is not possible for Spyder to create a console for you.
But I installed spyder-kernals in my venv, I can literally see them there, I set the path the the python installed in the venv, everything should work, but it doesn't!
Any thoughts?
I asked CAM Gerlach as suggested, and he spotted my error very quickly. The instructions at modular approach are correct except they say pip install spyder-kernels==0.* which I took literally. In fact as per the error message you need to use later versions, so I used pip install spyder-kernels==1.10 and it fixed it.
You may have to ask to "C.A.M. Gerlach" if he has an update on the procedure: Spyder has evolved a bit with Spyder-4.

How to check previous installed version number of SciPy using Anaconda?

I wrote some code months ago testing different optimizations of a function. I've since updated my anaconda installations of scipy, numpy, etc. that the code uses. Now the functions have different speeds (some faster, some slower), despite using the same code.
Is there anyway to check what the previous version of scipy that was installed was so I can attempt to see if something in scipy changed affecting my code? I use anaconda for package management, so I'm not sure if there's some record of previously installed versions somewhere. In particular I'd like to check cKDTree and cdist to see if either has changed in any meaningful way since my last installed version.

Packages missing from new install of Canopy Express

I just installed Canopy Express 1.4.1 (32-bit) for Windows. Among the packages that are supposed to be there (see https://www.enthought.com/products/canopy/package-index/ ) are pandas and statsmodels. But after installing, neither is listed in Package Manager, either as being installed or available.
The lack of pandas is not a problem, as pip easily installs it. (Enthought notes that packages installed that way will not be listed in Package Manager, but are fully available in the Canopy User Environment. Indeed, it imports.
statsmodels is not so easy. pip only gets source, and there is no Windows installer provided by the statsmodels folks. There is a nightly Windows binary, but not (if I'm reading correctly) for the stable build. The suggested solution by statsmodels is to compile it, using MinGW, which I do not currently have installed.
With enough trouble, I imagine I could compile and install, but is there a way to save all that trouble and get the packages within Canopy, as Enthought says it should be?
Seems like your Package Manager is misbehaving or you are looking in the wrong place (look in Free Packages not Community Packages).
Pandas is indeed in the Express installer, so always installed. At Canopy's python prompt, type:
import pandas
Though sounds like you've already overwritten it with pip, not really a problem but not the cleanest path (mixing 2 different installation methods for the same package).
Statsmodels is listed in package manager (Free package). It is available to free users but is not yet in the Express installer.
If you still don't see these in the pkg mgr, please quit Canopy, ensure that all Canopy processes have terminated (easiest way... log out of Windows, then back in), and restart Canopy.

Python with openCV on MAC crashes

My final goal is to use Python scripts with SciPy, NumPy, Theano and openCV libraries to write code for a machine learning application. Everything worked so far apart from the openCV.
I am trying to install openCV 2.4.8 to use in Python projects in my Eclipse Kepler installation on my MBA running Mac OSX 10.9.2. I have the PyDef plugin v2.7 and a installation of Anaconda v1.9.1.
Here is what I did to install opencv:
sudo port selfupdate
sudo port upgrade outdated
sudo port install opencv
Then I realized that I can't use it that way in Python and did another:
sudo port install opencv +python27
Ok, then I had another Python installation and I added it to my PYTHONPATH in Eclipse>Preferences>PyDev>Interpreter-Python>Libraries.
Before the installation I got an error in the line import cv2, and everything else looked promising. Now this error disappeared but I get other errors when using any functions or variables of cv2. For example I get two errors in this line: cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
Also Python crashes and has to be restarted when I run a simple test program which worked fine before.
With this PYTHONPATH everything works but I have no openCV:
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyObjC
/Library/Python/2.7/site-packages/
/Users/xxx/anaconda/lib/python2.7/site-packages
When I add this new folder to the PYTHONPATH...
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
... openCV seems to work but I have the crashes and the other issue described above.
So, can anyone tell me what the problem is and what I can do to make this work?
Thanks for reading this so far and any help/hint you can provide! Please don't be too harsh, I am, as you can probably easily see just a beginner.
Ok, it's working now. Here is what I did:
Install Python and every package I need for it with Macports
Set the Macports version as standard
Adjust PATH and PYTHONPATH
Reboot (not sure if needed)
Remove old interpreter and libs in Eclipse
Choose the new Python installation as Interpreter in Eclipse
Confirm the new libs in Eclipse
Restart Eclipse
Done

How to get an ipython graphical console on Windows 7?

Where can I find step-by-step instructions to install the modules required by ipython qtconsole in Windows 7 (64-bit)?
(Sorry for the brevity of this question. It would take literally hours for me to write down all the things I have attempted, and nearly as long for anyone to read it. I'll just note that everything that I have found even remotely related to pyqt4 seems extremely Unix-specific, with at most a cursory nod at what Windows users may try...)
After installing and adding Python paths to your Environment Variables:
Open Windows command line (cmd.exe) and run:
pip install ipython[all]
or as recommended by official site:
pip install qtconsole
After pip finished installing all the packages, you can start the ipython qtconsole by running:
ipython qtconsole
or
jupyter qtconsole
I would suggest using a full package distribution like EPD (http://www.enthought.com/products/epd_free.php), which should work out of the box.
Otherwise the dependencies are
ZeroMQ, pyzmq, PySide or PyQt, and pygments,
And unfortunately we don't have enough users using windows to improve the install docs.
On Windows, the 32-bit version of EPD is free; it runs fine on Win7-64, though of course with a 32-bit address space. This EPD installer include ipython 0.12.1, which suffices for qtconsole. To update it to ipython 0.13.1 (important for ipython notebook), use the EPD command "enpkg ipython" (details here).
I bought the Conceptive Engineering Python Stack. I give it a 6 out of 10 (for 50 USD). It does ship with many great binaries (QtConsole and friends included) and is geared for rapid Python+QT application development. It also covers some networking/web modules that are nice to have, all with a pretty good Windows installer (32-bit py platform).
I too am on 64bit Windows 7, and thats part of the reason I mark then down a little. A few of the packages are glitchy out of the box (tkinter was broken OUT-OF-BOX! but only on 64bit system). The thing with these guys (from belgium i think), the QT+Python "development suite" is really all they intend to deliver (luckily that includes a quite functional, albeit slightly dated IPython deployment).
The worst part is support (oh sure, they have $300 dollar 1-day class in germany). I don't expect emergency 24hour-phone service for $50, but they don't even ship a decent Readme, negligible website support docs; doesn't even have a package summary list of what they just slapped on your system. Feels like they ship you a big tarball, and if the applications they post on your start-menu don't satisfy your needs, get ready to go digging in your PYTHONPATH. Email support was shotty as well.
Although, I still havn't ditched it, the number of Qt4 related programs are pretty useful and hard to get done with other python deployments.
For what is worth...
I have a similar use case and wrote some helper batch scripts to deploy Miniconda, a stripped down version of the Anaconda Python distribution by continuum.io.
It also installs packages that I need, such as IPython for ipython qtconsole.
You can easily customize these scripts to suit your needs. They're for Windows x86_64 but can be configured for 32bit x86 as well.