OpenMDAO: First Steps - installation

I am new in the world of OpenMDAO (and also on Python) and I am having some problems to understand the use of the software. I have already installed Anaconda (pyth v2.7) and the OpenMDAO, but I don't know how to run it. I am following this tutorial but I am not sure if I am doing it properly. I write the .py files in notepad++, and I try to run on the IPython but when I use the command : from paraboloid import Paraboloid it appears an error : No module named.api. I think that maybe I am not using the correct path (I'm in the folder where I have the .py files). Probably it's an stupid error, so sorry for the question.
Thank you all, Jose M O

If your tutorial link above is correct, I see that you are using a tutorial for OpenMDAO 0.1.0. That version is 5.5 years old at this time, and is no longer supported. We will be happy to help with your questions, but to get a better foundation, and a much more useful tool, please consider:
Install OpenMDAO 1.5.0 (pip install openmdao or read these installation docs)
Try this paraboloid tutorial instead.
Good luck,
Keith
NOTE: If you installed OpenMDAO 1.x.x and are using the tutorial from 0.1.0, you would have many problems with api imports, as many things have changed since 0.1.0.

Related

Install numpy in Python 2.7 without setting environment

I wanted to install numpy in python 2.7 without setting environment path. I do not know if that is possible or not but my Professor wants it like so please any advice would be appreciated.
I am not sure I understand your question correctly. You can simply delete python from your environment path. But normally this is not desirable since you then cannot call python from any directory. Better is to create a virtual environment. Or better use: anaconda. This will allow you to use various version of pythons in separate environments without any confusion or clashes between versions. You then install the respective numpy version within a specific environment. See: https://conda.io/docs/user-guide/tasks/manage-python.html
If you mean want to install numpy but you do not have the previleges then your answer can be found here: (Python) Use a library locally instead of installing it
I hope this helps. If not, then please clarify your question.

Mocha, deep learning tool

I am new to deep learning, and have found a tool named "Mocha". This is the tool written in Julia. But I have confronted a bug while I was loading files. The program failed to read files, and I had no idea. The part of code is as follows:
using HDF5
datasets = ["train" => ["train-labels.idx1-ubyte","train-images.idx3-ubyte"],
"test" => ["t10k-labels.idx1-ubyte","t10k-images.idx3-ubyte"]]
The compiler reported that HDF5 is not installed properly. Does anybody know how to fix it?
Error is pretty clear, you need to install HDF5. On a mac (assuming you have homebrew) it would be brew install hdf5.rb
Check this link: https://github.com/JuliaIO/HDF5.jl
You can install HDF5 package for Julia by following instructions on the page.
And I wonder why you chose Julia based framework for Deep learning?

Problems installing Flagmatic

I'm trying to install Flagmatic on Mac OS X Yosemite, a software package used to solve problems in extremal graph theory using the "flag algebras" developed by Razborov. I'd like to use Flagmatic to help with a research problem I'm working on, but I'm finding it very difficult to install. I'm a mathematician and while I've had some experience using Sage and Python through the Terminal I don't really know how to fix the sort of problems that I'm running into here. Here's the most up-to-date user guide so you can follow what I'm trying to do. I can broadly break down the problem as follows:
First, there is a link in the user guide to download the semidefinite programming package CSDP which Flagmatic needs in order to do some calculations. You then need to move CSDP to somewhere Flagmatic can find it, so I typed
sudo cp ~/Downloads/csdp/usr/local/bin/
into Terminal, which seemed to work. Then the user guide says by typing
csdp
into Terminal it should launch CSDP. This doesn't work - I get a permission denied message even though I typed sudo. Can anyone explain why this is happening and how to remedy it?
Secondly, when I run Sage (maths software) in the Terminal, I then want to be able to change directory to the pkg folder where there is a script called setup.py. When I run sage and type
python setup.py install
or
-python setup.py install
while in the pkg directory, I get an invalid syntax message with a pointer to the particular phrase setup.py. This is what the user guide tells you to do. If I instead try to install outside of Sage I get an error message The environment variable SAGE_ROOT must be defined. Can anyone provide some explanation and help with how to fix this?
Wow, this is somewhat dated information that they provide, since for well over a year csdp is an experimental Sage package. You should be able to just do
sage -i csdp
to install it (if you have compiler tools, which you probably do in this case). I guess the old instructions would still work but are a little brittle w.r.t. Sage.
Anyway, to the actual problem. You need to do the exact command given in the instructions:
sage -python setup.py install
However, this assumes (!) that you have a sage command in your PATH. Which you may not!
In this case, I recommend you use whatever command you use to run Sage, but instead of just typing /commmand/for/sage do /command/for/sage -python setup.py install in that directory. It will have all the right environment variables set up so that it installs in the right place, I am guessing.
Now, I'm not sure why flagmatic isn't just having themselves become an upstream package on the Sage servers, but that is a question that is harder to answer.
I might udpate the documentation in the near future. For now, however, you might want to visit this: https://github.com/jsliacan/flagmatic-2.0.git. I keep Emil's copy of Flagmatic 2.0 with updated install info. If you follow the README file, you should be fine.
I just built sage on Yosemite from source (worked fine) and then installed Flagmatic 2.0 (or Flagmatic-dev) without difficulties. It should work for you too.
I hope this helps.

RQuantlib and Mac OS X 10.8.2

I'm a total newbie in Mac OS X, R and C++. Sound like a good mix, doesn't it?
I have the need to use RQuantLib, because I want to use some pricing functions part of the QuantLib package inside R, all on a Mac OS X-powered environment.
I've correctly installed QuantLib. I've already asked to the official QuantLib mailing list, and together we seem to have reached the conclusion that the problems I'm encountering are not related to my QuantLib installation, which seems ok and correctly configured.
So, I turned to R to try and solve the problem. Whenever I try to run ZeroCouponBond from within R, copying and pasting the first example provided with the official documentation, I get the following error:
"Error in DiscountCurve.default(discountCurve.param, list(flat = 0.05)) :
cannot find function errorOccured"
Now, I would rule any syntax.related problem out, since I'm copying the very same example present in the official help.
I don't know what I did wrong, but I know I need to find a solution at all costs. I've installed Rcpp, and the configuration seems really ok. Just one question I was not able to find an answert to: in my understanding, RQuantLib basically acts as a link between QuantLib and R. If that's correct, how can I tell RQuantLib where to look to find libQuantLib.a, that is, the compiled library resulting from the "make && sudo make install" commands performed while installing QuantLib itself?
Right, so, I've finally managed to get it to work.
First of all, I would like to say that things would have been much easier if a thorough, step-by-step installation procedure had been provided. I acknowledge I'm a total newbie, but I think other people approaching to R for the first time might encounter difficulties similar to those I had to overcome.
Anyway, this is what I did:
I've downloaded the .tar.gz source packages for both Rcpp and RQuantLib from cran.r-project.org
I've compiled them installing them from within the R environment. This is where I was making a mistake. Indeed, I was trying to compile them by invoking the configure installation script from the terminal; however, as Dirk said, the config script looks for QuantLib's quantlib-config script, and I didn't know the correct syntax to tell the configure script the correct path to QuantLib. Executing the procedure from R (by just installing the package) sorts out any problem, as all the dependencies are correctly located and loaded
So, that's pretty much it: just install the .tar.gz source package as you would do with the binary version, and everything should work ok.
Of course, I'm still curious to understand:
If it is possible to compile Rcpp and RQuantLib from the terminal; and
Why the binary version for Mac OS X will not work on my system, ie: why do I have to compile starting from the source code?
Thank you so much to anyone willing to answer my (probably naive and silly) questions. I'm eager to understand a bit more!
Thanks!
The RQuantLib package uses a tool called configure which determines the patch at package build-time. It looks for the script quantlib-config from which it learns about the location of libQuantLib.a.
First, install boost (brew install boost) and, secondly, Quantlib (currently at 1.7.1) by following instructions at http://quantlib.org/install/macosx.shtml:
cd QuantLib-1.x.y
./configure --enable-static --with-boost-include=/opt/local/include/ \
--with-boost-lib=/opt/local/lib/ --prefix=/opt/local/
make && sudo make install
It takes some time (~1 hour) for make.
Then in R or Rstudio, install packages Rcpp and RQuantlib. The later requires type="source" since only source package is available.
At this point, you should be able to use RQuantlib. The American Option value (SPY as of 4/1/2016, maturity 7/15/2016) can be calculated in R as
AmericanOption("put", strike=206, volatility=0.1525, underlying = 206.92, 0.021, 0.003, 73/252, engine="CrankNicolson")

Totally Lost on "Installing" OpenCV / ctypes-opencv for Python 3

edit: The real solution to this is now that OpenCV supports python 3. I'm leaving the details below for anyone who happens to be stuck with an old setup.
I'm trying to get OpenCV working with Python 3. A friend showed me ctypes-opencv that appears to work with Python 3. The problem is I totally can not figure out how to "install" or get any code working. I've followed all instructions I could find from a few people mentioning installs on google and none of those seemed to work or I couldn't even get through the basics that they mentioned.
I am just hacking around with the version of IDLE that came with Python 3. No IDE.
Start with OpenCV:
The only windows installer for OpenCV 2.1 is a visual studio installer. I assume that means that it installs files that make it easier to use in Visual Studio. However, does it also mean that I can't use that installer with Python 3? I tried the vs installer together with ctypes-opencv as below, and I got errors that the dlls were not in my path (but my path variable did include the OpenCV bin folder with dlls). Is this the wrong direction?
The apparent alternative is to build OpenCV myself. I tried following the directions here and all I get is "project files may be invalid" from the CMake gui application when pressing the "Configure" button. Same when following these hints from Stack Overflow. I'm suspicious that this is also the wrong direction since I am not currently using any of the tools that are listed in the CMake configure. Is this also the wrong direction?
Next ctypes-opencv:
I installed this and the installer recognizes Python3.1 and puts itself into the site-packages folder. If I try to run demos, it tells me the dlls are not in the path although they are, as mentioned above.
Summary:
I think I generally understand each piece here (code, compile, dll, imports, ...) but I do not know how all the pieces fit together and where I am going wrong. Can someone please tell me what steps or understanding I am missing here?
I get the feeling that I need to be reading a book or two to fill in the holes in my understanding of how all these pieces fit together. I wouldn't even know what area of books to get though so any suggestions there would be appreciated as well.
Python's ctypes is a wrapper around the opencv dll files, as long as you can point to the compiled libraries it doesn't matter what the source code is set up to be edited in. For windows I would simply run the installer, then try to load the dll with ctypes. If you can get that far, any other errors can be fixed by looking at the ctypes wrapper file and editing the load section to look like your test file.
Christoph Gohlke maintains Windows binaries for many Python packages, including the production version of OpenCV 3.0 with Python 3.x bindings, released 4 June 2015:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
To install, just download the 64-bit or 32-bit .whl file appropriate for your system, then run pip install [filename]. Then the instruction import cv2 should work in your Python 3.x interpreter.
Yakiimo san, OpenCV 2.1 DLL can be loaded with ctypes. I have tested it.
p.s. I have set the C;\OpenCV2.1\bin in Env Path.

Resources