Version 14 (modified by toby, 2 years ago) (diff) |
---|
Installing GSAS-II via conda (Anaconda Python)
Many Python enthusiasts use the Anaconda package manager to install Python on their computer. GSAS-II can be installed using a simple conda command, after installing anaconda or miniconda. We are currently recommending Python 3.7 or 3.8. (At the time this is being written, mid-January 2021, Python 3.9 is available in conda, but wxPython is not, nor have GSAS-II binaries been prepared). When the gsas2pkg conda package is used, it ensures that the packages required by GSAS-II are installed, including subversion, and then subversion is used to download the latest version of GSAS-II from the APS server. This download will fail if your computer network requires a proxy (more info on proxies here), but rerunning the bootstrap.py command (see bottom of this page) will request this proxy information and should install these files.
conda install gsas2pkg -c briantoby
If the conda environment fails to solve, this is likely because Anaconda is not supplying a compatible wxpython package or you have previously installed some other package that conflicts with GSAS-II's required packages. As I write this, wxPython is not available for Python 3.8 in the standard package repository, but is in the conda-forge channel. To access that, add -c defaults -c conda-forge before -c briantoby in the above command so that it becomes:
conda install gsas2pkg -c defaults -c conda-forge -c briantoby
Alternatively, one can force regression to an older version of Python with this command:
conda install python=3.7 gsas2pkg -c briantoby
If conflicts persist, you are best off installing GSAS-II in a named environment (see below).
For Python 3.9, one must install wxPython via pip, which sort of defeats the purpose of using Anaconda. Again, use of a named environment (see below) is advised.
After the conda install completes, one of the following should occur:
- On MacOS, an app is created that can be dragged to the doc (or create a shortcut to GSAS-II.app and drag that anywhere).
- On Windows a desktop shortcut is created.
- On Linux (at present) the command-line is needed to start GSAS-II:
source <condapath>/bin/activate python <condapath>/GSASII/GSASII.py
Where <condapath> is the location where anaconda/miniconda was installed. These commands can be found in file <condapath>/start_GSASII.sh or on windows <condapath>\start_GSASII.bat`
Using a Conda Environment
It can be a good idea to place GSAS-II in a separate environment so that package versions do not conflict. This is recommended if you have any other packages with particular version dependencies. To use a separate conda environment for GSAS-II, (here named G2,) use these commands to install GSAS-II:
conda create gsas2pkg=2 -c briantoby -n G2
Note that the GSAS-II files will be placed in <conda>/env/G2/GSAS-II.
To run GSAS-II, you will need to activate the environment manually before starting GSAS-II (conda activate G2).
- On Windows manually edit the runGSASII.bat file to add this.
- On Mac OS X the created application seems to work OK (or use commands in <condapath>/start_GSASII.sh).
- On Linux use these use these commands:
source <condapath>/bin/activate G2 python <condapath>/envs/G2/GSASII/GSASII.py
Where <condapath> is the location where anaconda/miniconda was installed. These commands can be found in file <condapath>/start_GSASII.sh
Activating
If you get an error that conda is an unknown command, this means anaconda/miniconda is not in your path (which is my recommended way to install anaconda) and you will need to first use the activate command:
- mac/linux:
source <condapath>/bin/activate
- windows:
<condapath>\Scripts\activate
With GSAS-II in an environment, the activate command becomes ...activate G2
Python 2.7: We strongly discouraging use of Python 2.7 and are no longer testing GSAS-II compatiblity with Python 2.7 (but will usually fix problems, if reported).
GSAS-II Updates
Note that updates to GSAS-II are not integrated into conda and are not coupled to the specific versions of Python packages you have loaded. To obtain the latest version GSAS-II (you are strongly recommended to update regularly) use the Help/Update menu command or rerun the bootstrap.py script using this command:
<condapath>/bin/python <condapath>/GSASII/bootstrap.py
Running bootstrap.py
To rerun the bootstrap.py script using the python package you have installed with this command in a terminal/cmd.exe window
Windows:
<condapath>\Scripts\activate python <condapath>\GSASII\bootstrap.py
Linux/OSX:
source <condapath>/bin/activate python <condapath>/GSASII/bootstrap.py
These commands can be found in file <condapath>/start_G2_bootstrap.sh or on windows <condapath>\start_G2_bootstrap.bat
(note that with a Conda environment named G2 change activate to activate G2 and the file path changes to <condapath>/envs/G2/GSASII/bootstrap.py.
Downloading multiple binary files
GSAS-II will automatically attempt to download the appropriate binary files to match the host OS and the versions of Python and numpy that are in use. This is not a good thing on a server or where multiple versions of Python are in use (for example for code development). In these cases, it is best to download the binary files available for all supported platforms. Use of this command will do that:
<pypath>python bootstrap.py -server
Notes on anaconda installation
Here are commands that worked for me recently on Linux.
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > /tmp/Miniconda3-latest-Linux-x86_64.sh bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /tmp/conda3 source /tmp/conda3/bin/activate conda update --all conda install python=3.7 gsas2pkg -c briantoby bash /tmp/conda3/start_GSASII.sh
To create GSAS-II in an environment I used this:
conda create -n G2 gsas2pkg-linux -c briantoby
To create a Python for running GSAS-II without installing GSAS-II, I used this (after installing miniconda and activating):
$ conda update conda $ conda install wxpython matplotlib numpy scipy pyopengl pillow h5py imageio svn pywin32 python=3.7
or with an environment:
$ conda create wxpython matplotlib numpy scipy pyopengl pillow h5py imageio svn pywin32 python=3.7 -n g2env
Note that pywin32 is needed only on Windows and I downgraded to 3.7 because that is the only wxpython available from anaconda (later by pip and conda-forge).