|
| 1 | +# Installing PYME on windows 10 |
| 2 | + |
| 3 | +## Installation customised for Soellerlab at the University of Exeter |
| 4 | + |
| 5 | + |
| 6 | +This is a custom install that should ultimately work on most windows 10 machines. The install has the goal to make access to the latest code available relatively easily. It also reflects the relatively recent move of most code to github. |
| 7 | + |
| 8 | +### This page is focused on py3 |
| 9 | + |
| 10 | +**NOTE**: This guide focuses on a python 3.7 based install. Python 2.x based installs are discouraged as we are now beyond the supported lifetime of python 2.X. |
| 11 | + |
| 12 | +### Installation overview |
| 13 | + |
| 14 | +The complete install can be broken down into a few higher level steps as follows: |
| 15 | + |
| 16 | +1. Install the Anaconda python packaging system. |
| 17 | + |
| 18 | +2. Install a github client to allow downloading the latest code from our code repositories. |
| 19 | + |
| 20 | +3. Download the relevant code repositories using the github client. |
| 21 | + |
| 22 | +4. Install a c/c++ compiler. |
| 23 | + |
| 24 | +4. Build the main code packages using their respective setup procedures. |
| 25 | + |
| 26 | +5. Make a few shortcut files etc to simplify launching the various apps (visgui, dh5view, etc). |
| 27 | + |
| 28 | +6. Test the install. |
| 29 | + |
| 30 | +#### 1. Install the Anaconda packaging system |
| 31 | + |
| 32 | +##### Step 1: Install Miniconda |
| 33 | + |
| 34 | +Just follow the [STEP 1 paragraph](http://python-microscopy.org/doc/Installation/InstallationWithAnaconda.html#step-1-installing-miniconda) at David's site. |
| 35 | + |
| 36 | +##### Step 2: Open an anaconda prompt |
| 37 | + |
| 38 | +Your start menu should contain an anaconda prompt command something like the one below: |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +This should open a command window, that has the ```(base)``` label at the beginning, indicating you are running in the base environment: |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +##### Step 3: Create the PYME default environment |
| 47 | + |
| 48 | +In the anaconda prompt window type the next 2 commands, one after another: |
| 49 | + |
| 50 | +```python |
| 51 | +conda config --add channels david_baddeley |
| 52 | +conda create --name pyme-py37 python=3.7 pyme-depends |
| 53 | +``` |
| 54 | + |
| 55 | +##### Step 4: Activate the PYME default environment |
| 56 | + |
| 57 | +Now activate the new conda environment in your anaconda prompt window by typing: |
| 58 | + |
| 59 | + conda activate pyme-py37 |
| 60 | + |
| 61 | +This should change your command prompt to show that you are now within the pyme-py3 environment, i.e. ```(base)``` has changed to ```(pyme-py37)``` (in the screenshot below we demonstrate this with an environment called `pyme-default-plain`): |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +##### Step 5: Small fixes to correct conda issues |
| 66 | + |
| 67 | +Currently there seem to be no fixes required (as of March 2021). |
| 68 | + |
| 69 | +#### 2. Install a github client |
| 70 | + |
| 71 | +Our new repositories are kept on github (previously they were on bitbucket). We therefore need a suitable github client. |
| 72 | + |
| 73 | +The currently preferred option is an app called `gitkraken`. |
| 74 | + |
| 75 | +##### Install gitkraken |
| 76 | + |
| 77 | +My preferred git client at the moment is [gitkraken](https://gitkraken.com/git-client). Download the version for your computer and operating system. You need to make a gitkraken login (I seem to remember) and sign up for the free plan upon starting up the gitkraken app. |
| 78 | + |
| 79 | +I forget if gitkraken also asks you for a github account, I should think it is not really needed if we only download repositories. So I think you should get away without registering a github account explicitly. |
| 80 | + |
| 81 | +The next step is to clone a repository from github using gitkraken. |
| 82 | + |
| 83 | +#### 3. Clone the relevant code repositories using the github client |
| 84 | + |
| 85 | +##### Clone the python-microscopy repository |
| 86 | + |
| 87 | +Using gitkraken, select the ```clone repository``` functionality, as shown below: |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +Now grab the URL for the python-microscopy repository. This is done by going to the github website for the [python-microscopy repository](https://github.com/python-microscopy/python-microscopy). As shown below, make sure you have chosen HTTPS access and click the button to get the URL into the clipboard: |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +Then paste the URL into the `gitkraken` URL box as shown below. |
| 97 | + |
| 98 | +Also select a base directory where the repository will reside on your disk. This should be a suitable directory on your hard disk, for example, somewhere in your documents folder. Note that we should select a common parent folder for our repositories, which will go into individual subfolders in the is common parent directory. The screenshot below shows a subfolder on my macbook, so that may look a little different from your machine. |
| 99 | + |
| 100 | +Finally, press the button to clone the repo. Cloning itself may take a little while until files are downloaded. Gitkraken should provide some kind of progress message. |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +##### Clone the PYME-extra repository |
| 106 | + |
| 107 | +The steps are identical to the ones above to clone the python-microscopy repository, with the single difference being the URL you need to obtain. You obtain the URL from the PYME-extra github site [https://github.com/csoeller/PYME-extra](https://github.com/csoeller/PYME-extra) as shown below: |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +Once done paste the URL into the suitable box in gitkraken as was |
| 112 | +illustrated in detail above. Finally, press the button to clone the repo. |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +#### 4. Install a c/c++ compiler |
| 117 | + |
| 118 | +##### For current builds use Microsoft Build Tools for Visual Studio 2019 |
| 119 | + |
| 120 | +For current builds of PYME a suitable compiler must be installed. Some details on compiler choices can be found on this page about [windows compiler choices for python](https://wiki.python.org/moin/WindowsCompilers). This suggests [Microsoft Build Tools for Visual Studio 2019](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2019) as a recent and functional choice which we describe in further detail below. Apparently, recent anaconda/minconda installs will suggest this one during the installation and lead the user through the compiler installation process (but I have not tried this yet). |
| 121 | + |
| 122 | +I have so far tested installing this compiler manually on a win10 system that has an existing anconda install and also already had *MS Visual C for Python 2.7* on it. |
| 123 | + |
| 124 | +I downloaded the installer from the [Microsoft Build Tools for Visual Studio 2019](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2019) link and then ran it. |
| 125 | + |
| 126 | +This brought up a window to select the components to install. I only ticked the C++ build tools option, as shown below. I then pressed the `Install` button which took a little while to complete (6GB of stuff I think) and then asked me to reboot. Since then I have been able to successfully build a py3 based PYME from the latest github sources with this compiler. So should be good! |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | +#### 5. Build the main code packages using their respective setup procedures. |
| 131 | + |
| 132 | +##### Build python-microscopy |
| 133 | + |
| 134 | +1. Make sure you are using the anaconda prompt as you had used above. |
| 135 | + |
| 136 | +2. Next make sure you have activated the pyme-py37 environment. Remember that you only need to use the ```conda activate``` command if you do not yet see the ```(pyme-py37)``` at the command prompt, but rather ```(base)``` or something similar. If necessary, issue the command: |
| 137 | + |
| 138 | + conda activate pyme-py37 |
| 139 | + |
| 140 | +This should change your command prompt to show that you are within the pyme-py37 environment, i.e. ```(base)``` has changed to ```(pyme-py37)```. |
| 141 | + |
| 142 | +3. Now cd into the base directory of the python-microscopy repository on your disk. *This directory will be different for each machine* and is where you previously cloned the python-microscopy repository. That directory should contain a file ```setup.py``` as well as the subdirectory ```PYME``` and a bunch of other things. |
| 143 | + |
| 144 | +4. Once in the right directory, issue the command to build python-microscopy in development mode: |
| 145 | + |
| 146 | + python setup.py develop |
| 147 | + |
| 148 | +This will build PYME and will take a little while to compile all the code etc. During this time a lot of messages will be printed to the screen. Some of these will be compiler warnings which can be safely ignored. |
| 149 | + |
| 150 | +**If you encounter errors**: best practice is to select **all text** in the command window using `<Ctrl-A>`, copy with `<Ctrl-C>` and paste using `<Ctrl-V>` into an empty `notepad` editor window, then save as something like `myinstall-log.txt` or similar. Then upload the file somewhere where we can all inspect it. |
| 151 | + |
| 152 | +Everything going well, you should now be able to test the installation for the ability to call dh5view and visgui from the command line, e.g., type, at the same command prompt you used for building PYME: |
| 153 | + |
| 154 | + dh5view -t -m lite |
| 155 | + |
| 156 | +This should bring up dh5view with a small image containing random noise, as shown here |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +##### Build PYME-extra |
| 163 | + |
| 164 | +1. Make sure you are using the anaconda prompt as you had used above. |
| 165 | + |
| 166 | +2. Next make sure you have activated the pyme-py3 environment. Remember that you only need to use the ```conda activate``` command if you do not yet see the ```(pyme-py37)``` at the command prompt, but rather ```(base)``` or something similar. If necessary, issue the command: |
| 167 | + |
| 168 | + conda activate pyme-py37 |
| 169 | + |
| 170 | +This should change your command prompt to show that you are within the pyme-py37 environment, i.e. ```(base)``` has changed to ```(pyme-py37)```. |
| 171 | + |
| 172 | +3. Now cd into the base directory of the ```pyme-extra``` repository on your disk. That directory should contain a file ```install_plugins.py``` as well as the subdirectory ```PYMEcs``` and a bunch of other things. |
| 173 | + |
| 174 | +4. We need one extra step to make sure that the FRC functionality works properly. This is achieved by installing the ```statsmodels``` package: |
| 175 | + |
| 176 | + conda install statsmodels |
| 177 | + |
| 178 | +5. Assuming the previous step worked fine, now it is time to build the PYME-extra code: |
| 179 | + |
| 180 | + # make sure you are in a terminal where the enviroment is activated!!!! |
| 181 | + # |
| 182 | + # normally you activate the environment first with |
| 183 | + # omit this next step if you are already in the environment in the command shell |
| 184 | + conda activate pyme-py37 |
| 185 | + # cd to the PYME-extra subdirectory before issuing the commands below! |
| 186 | + |
| 187 | + python setup.py develop |
| 188 | + python install_plugins.py |
| 189 | + |
| 190 | +Note that we leave out the ```dist``` argument in the plugin install call since we are installing to your local login. We could probably also install to dist, but I want to try it like this first. |
| 191 | + |
| 192 | +6. Test: At this stage you should bring up visgui again, say, and check that all the expected extra menus are available. [*Note to self, show what menus should be available*] |
| 193 | + |
| 194 | + |
| 195 | +#### 6. Make a few shortcut files and launchers |
| 196 | + |
| 197 | +The details for this part of the install have gone into their own document which you can find in this repository. |
| 198 | + |
| 199 | +#### 7. Testing the install |
| 200 | + |
| 201 | +Tests have been described above in various parts of the install. Please check out the various steps for details. |
0 commit comments