WinPython is a convenient python distribution package which contains most needed packages for Windows. After downloading you may start by installing the version with PyQt5 included and it in:
c:\winpyton
In the script winpython-notebook.bat add the line: cd/D PATH_TO_YOUR_NEW_NOTEBOOK_DIR
in order to jump immediately to the preferred place next time you run Jupyter Notebook.
#####GIT-BASH
I suggest installing git bash because basically it has all that you need. Create a shortcut of git bash for the desktop and change start in
to your home directory. GIT-BASH beings a small set of MINGW with it.
#####Environmental variables under Windows Accessible in the Control Panel:
- HOME: a preferred place. I usually put it F: where my data partition is.
- PATH:
WINPYTHON-INSTALL-DIRECTORY\python-3.4.4.amd64
WINPYTHON-INSTALL-DIRECTORY\python-3.4.4.amd64\Scripts
- `WINPYTHON-INSTALL-DIRECTORY\python-3.4.4.amd64\share\mingwpy\bin
WINPYTHON-INSTALL-DIRECTORY\tools
- PYTHONPATH:
- set this variable to your local library directories. I usually set this to my GIT directory full of libraries
###Direct installation ####Python + PyQt5
First of all you need Python and PyQt5. But the best approach is to first check which version of PyQt5 is compiled with at this website. Then download that version of Python from here. For example the file PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x64.exe
which uses needs python-3.4.4.amd64.msi
. After installing these, you are ready to go.
On some windows versions, python msi installer gives a cryptic error message. Usually this is solved by allowing the current user to have full control permission on C:\Users\USENAME\AppData\Local\Temp
.
####Win specific packages via pip
Other packages can be installed using pip
. I install the following packages provided by carlkl:
pip install -i https://pypi.anaconda.org/mingwpy/simple numpy
pip install -i https://pypi.anaconda.org/mingwpy/simple scipy
pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy
Another ready made package for spectrum
can be found here, which you need to install after installing matplotlib
and easydev
from pip
:
pip install -i https://pypi.anaconda.org/carlkl/simple spectrum
If during the compilation you get the error message
cannot find vcvarsal.bat
then you still need to tell the system that your compiler is gcc
. For that you need to find out where is your home directory in your msys
or other shell you are using. For that type
cd
pwd
Then you should see your home directory. Then you should create a file there with the name: pydistutils.cfg
with the following content:
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
After that compiliations should work like a charm. You may also need:
pip install py2exe h5py
###Compressing using UPX
Using UPX the size of the resulting compilation under windows can be reduced by the following command:
upx --best --lzma --compress-exports=0 --strip-relocs=0 *.pyd *.dll
###Under OSX
####Python + QT5
Some things need to be installed via macports
. First you need to install QT5 using ports:
sudo port install qt5
On the current version of the OSX, the installation of qt5 interrupts several times with errors, with some suggestions. Do as the command prompt suggests and repeat the qt5 installation again and again. After several attempts it will finally install.
Enter these commands one by one:
sudo port install python34 py34-pip py34-scipy py34-numpy py34-pyqt5 py34-pyfftw
sudo port select --set python python34
sudo port select --set pip pip34
sudo ln -s /opt/local/bin/gfortran-mp-5 /opt/local/bin/gfortran
This has the advantage that gfortran
will be installed as well. On some OSX terminals after an interactive python
session, the cursor disappears. In order to prevent that, additionally to the above you may:
sudo port install python34 +readline
####OSX specific packages via pip
sudo -H pip install spectrum py2app
On a personal mac, where you have also sudo rights, it doesn't matter if you install pip packages using sudo or in your user home. The first case is like:
sudo -H pip install pip-autoremove
which installs the libraries in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/
or without sudo
like:
pip install pip-autoremove --user
which installs everything in ~/Library/Python/3.4/lib
. Some of the pip packages have a binary version that are also installed either in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/
or in the user's home under ~/Library/Python/3.4/bin
.
In either way you should add this path to your .bash_profile so that you can run that binary.
PATH=$PATH:/opt/local/bin:/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin
export PATH
After installing all other packages, you if you need CERN ROOT then you can install it using macports. But before that, it is needed to instruct port
to use the current python version. To do that, one has to change an entry in the portfile
of root6
port. Locate that file using:
port file root6
It will find a file somewhere like /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/science/root6/Portfile
. Make a backup somewhere, edit it with sudo
, go down and search for the entry:
set default_python_variant +python27
and change it to:
set default_python_variant +python34
now if you install the port:
port install root6
you will have ROOT with python 3.4 support through PyROOT. You can verify this by importing ROOT, but also by checking the output of:
port contents root6 | grep ROOT.py
and
port contents root6 | grep libPyROOT.so
and see that they are found and are pointing to version 3.4. It should be mentioned that it should be possible to go about the whole procedure above by just typing:
sudo port install root6 +python34
but I have never given it a try.
There exists also an alternative implementation called rootpy. This can be installed via pip
:
sudo -H pip install rootpy
You need to source thisroot.sh
:
source `which thisroot.sh`
note the upper back quotes. Then you can test your overall installation by:
python -c 'import rootpy'
If there are no errors, then everything is fine. This can also be done before starting the Jupyter notebook session. My successful combination is:
Python 3.4.5 +readline
root v. 6.06/08 +python34 from Macports on OSX 10.11.6 El Capitan
rootpy 0.8.3 by PIP
good luck!