Wiki source code of Anaconda Python at FLASH
Last modified by sndueste on 2025/02/05 11:23
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
29.2 | 1 | === === |
2 | |||
3 | == (% style="color:#e74c3c" %)**OUTDATED (Dec 2024) ... to be adapted to current situation ...**(%%) == | ||
4 | |||
5 | === === | ||
6 | |||
7 | === === | ||
8 | |||
9 | === Maxwell === | ||
10 | |||
11 | ==== TL;DR ==== | ||
12 | |||
13 | The usual work flow, in case Anaconda is set-up: | ||
14 | |||
15 | (note that this is only tested for{{code language="none"}} bash{{/code}} shell !) | ||
16 | |||
17 | {{code language="bash"}} | ||
18 | $ source activate flash | ||
19 | (flash)$ ipython | ||
20 | [0]: import pydoocs | ||
21 | ... | ||
22 | [999]: exit | ||
23 | (flash)$ conda deactivate | ||
24 | |||
25 | {{/code}} | ||
26 | |||
27 | ==== Anaconda Python environments and package installs at Maxwell ==== | ||
28 | |||
29 | The default Pythons change frequently on Maxwell. We suggest to always load a specific Anaconda module and to add the module load command to your {{code language="none"}}.bashrc{{/code}} file. The environments you create here, are then also selectable on Maxwell's central [[JupyterHub>>doc:FLASHUSER.Data Acquisition and controls.DAQ and controls overview.Online data analysis.Anaconda Python at FLASH.JupyterHub on Maxwell.WebHome]]. | ||
30 | |||
31 | This example uses the Anaconda module {{code language="none"}}anaconda3/5.2{{/code}}. This is loaded by the command | ||
32 | |||
33 | {{code language="bash"}} | ||
34 | module load anaconda3/5.2 | ||
35 | |||
36 | {{/code}} | ||
37 | |||
38 | By the way, to check which modules are loaded do | ||
39 | |||
40 | {{code language="bash"}} | ||
41 | module list | ||
42 | {{/code}} | ||
43 | |||
44 | To list available Anaconda channels (i.e. Anaconda package sources): | ||
45 | |||
46 | {{code language="bash"}} | ||
47 | conda info | ||
48 | {{/code}} | ||
49 | |||
50 | To add the FLASH channels, i.e. the sources of the FLASH software not available in standard, preconfigured sources: | ||
51 | |||
52 | {{code language="bash" title="lavue, opisgraph, ramanometer ..."}} | ||
53 | conda config --add channels http://doocspkgs.desy.de/pub/flashconda | ||
54 | {{/code}} | ||
55 | |||
56 | {{code language="bash" title="Pydoocs and Pydaq"}} | ||
57 | conda config --add channels http://doocspkgs.desy.de/pub/doocsconda | ||
58 | {{/code}} | ||
59 | |||
60 | To list available Anaconda virtual Python environments | ||
61 | |||
62 | {{code language="bash"}} | ||
63 | conda info --envs | ||
64 | {{/code}} | ||
65 | |||
66 | To create your own environment, e.g. named {{code language="none"}}flash{{/code}}: | ||
67 | |||
68 | {{code language="bash"}} | ||
69 | conda create -n flash python=3.6 ipykernel | ||
70 | {{/code}} | ||
71 | |||
72 | Note, {{code language="none"}}ipykernel{{/code}} is required, if you want to use the central [[JupyterHub>>doc:FLASHUSER.Data Acquisition and controls.DAQ and controls overview.Online data analysis.Anaconda Python at FLASH.JupyterHub on Maxwell.WebHome]] installation on Maxwell. We do recommend to include {{code language="none"}}ipykernel{{/code}}. | ||
73 | |||
74 | Also note, if you choose Python version 3.6 on any of the Maxwell nodes, you also have to downgrade the //prompt_tookit// to version 2.0.10. Execute the command | ||
75 | |||
76 | {{code language="bash"}} | ||
77 | pip3 install --upgrade --user prompt_toolkit==2.0.10 | ||
78 | {{/code}} | ||
79 | |||
80 | To activate the environment named {{code language="none"}}flash{{/code}}: | ||
81 | |||
82 | {{code language="bash"}} | ||
83 | source activate flash | ||
84 | {{/code}} | ||
85 | |||
86 | The active environment is shown enclosed in parentheses in front of the shell's command prompt. | ||
87 | |||
88 | To list the Anaconda packages available in your active environment: | ||
89 | |||
90 | {{code language="bash"}} | ||
91 | conda list | ||
92 | {{/code}} | ||
93 | |||
94 | To permanently install e.g. [[pydoocs>>doc:FLASHUSER.Data Acquisition and controls.Data Access at FLASH (DAQ, gpfs,\.\.\.).Online data analysis.PythonDOOCS.WebHome]] into your active environment: | ||
95 | |||
96 | {{code language="bash"}} | ||
97 | conda install pydoocs | ||
98 | {{/code}} | ||
99 | |||
100 | To deactivate the environment: | ||
101 | |||
102 | {{code language="bash"}} | ||
103 | conda deactivate | ||
104 | {{/code}} | ||
105 | |||
106 | === flashlxuser1 and 2, hasfcons0 to hasfcons15, haskcons0 to haskcons3 === | ||
107 | |||
108 | |||
109 | ==== TL;DR ==== | ||
110 | |||
111 | The usual work flow, in case Anaconda is set-up: | ||
112 | |||
113 | (note that this is only tested for{{code language="none"}} bash{{/code}} shell !) | ||
114 | |||
115 | {{code language="bash"}} | ||
116 | $ source activate flash | ||
117 | (flash)$ ipython | ||
118 | [0]: import pydoocs | ||
119 | ... | ||
120 | [999]: exit | ||
121 | (flash)$ conda deactivate | ||
122 | |||
123 | {{/code}} | ||
124 | |||
125 | ==== Anaconda Python environments at flashlxuser[1, 2] and hasfcons[0-15], haskcons[0-3] ==== | ||
126 | |||
127 | Anaconda is not the default on the user workstations and consoles in the FLASH halls or the FLASH servers flashlxuser1 and 2. On the consoles the module system does not contain an Anaconda module. Yet, a current Anaconda distribution is installed on all these machines at {{code language="none"}}/opt/conda/{{/code}}. | ||
128 | |||
129 | To list available Anaconda channels (i.e. Anaconda package sources): | ||
130 | |||
131 | {{code language="bash"}} | ||
132 | conda info | ||
133 | {{/code}} | ||
134 | |||
135 | To add the FLASH channels, i.e. the sources of the FLASH software not available in standard, preconfigured sources: | ||
136 | |||
137 | {{code language="bash" title="lavue, opisgraph, ramanometer ..."}} | ||
138 | conda config --add channels http://doocspkgs.desy.de/pub/flashconda | ||
139 | {{/code}} | ||
140 | |||
141 | {{code language="bash" title="Pydoocs, only within the DESY network"}} | ||
142 | conda config --add channels http://doocspkgs.desy.de/pub/doocsconda | ||
143 | {{/code}} | ||
144 | |||
145 | To list available Anaconda virtual Python environments | ||
146 | |||
147 | {{code language="bash"}} | ||
148 | conda info --envs | ||
149 | {{/code}} | ||
150 | |||
151 | To create your own environment, e.g. named {{code language="none"}}flash{{/code}}, choosing your favourite Python version. Pydoocs packages are available for version 2.7, 3.6, and 3.7. Here we select the most recent 3.7. We recommend to include {{code language="none"}}ipykernel{{/code}} for the IPython console and Jupyter Notebooks. | ||
152 | |||
153 | {{code language="bash"}} | ||
154 | conda create -n flash python=3.7 ipykernel | ||
155 | {{/code}} | ||
156 | |||
157 | To activate the environment named {{code language="none"}}flash{{/code}} (note, this intentionally differs from the output of the previous command): | ||
158 | |||
159 | {{code language="bash"}} | ||
160 | source activate flash | ||
161 | {{/code}} | ||
162 | |||
163 | The active environment is shown in parentheses in front of the shell's command prompt. | ||
164 | |||
165 | To list the Anaconda packages available in your active environment: | ||
166 | |||
167 | {{code language="bash"}} | ||
168 | conda list | ||
169 | {{/code}} | ||
170 | |||
171 | (% class="code" %) | ||
172 | ((( | ||
173 | To permanently install e.g. Pydoocs into your active environment: | ||
174 | ))) | ||
175 | |||
176 | {{code language="bash"}} | ||
177 | conda install pydoocs | ||
178 | {{/code}} | ||
179 | |||
180 | To deactivate the environment: | ||
181 | |||
182 | {{code language="bash"}} | ||
183 | conda deactivate | ||
184 | {{/code}} | ||
185 | |||
186 | To remove an environment named {{code language="none"}}test{{/code}} permanently: | ||
187 | |||
188 | {{code language="bash"}} | ||
189 | conda env remove --name test | ||
190 | {{/code}} | ||
191 | |||
192 | === Caveat - flashlxuser[1,2] === | ||
193 | |||
194 | As no there is no alias for {{code language="none"}}conda{{/code}} on flahlxuser1 & flashlxuser2 - Use: | ||
195 | |||
196 | {{code language="bash"}} | ||
197 | /opt/conda/bin/conda | ||
198 | {{/code}} | ||
199 | |||
200 | === References === | ||
201 | |||
202 | |||
203 | * [[Conda cheat sheet>>url:https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html||rel="nofollow" shape="rect" class="external-link"]] | ||
204 | * [[How to use Conda environments with JupyterHub in screen shots>>attach:conda_on_jupyterhub.pdf]] | ||
205 | * [[doc:FLASHUSER.Data Acquisition and controls.DAQ and controls overview.Online data analysis.Anaconda Python at FLASH.JupyterHub on Maxwell.WebHome]] | ||
206 | |||
207 | * [[attach:anaconda_and_venv.pdf]]: Christopher Behrens on Benefits of Anaconda and Virtual Envronments, 2019-01-14 | ||
208 | * [[attach:conda_server.pdf]]: Christopher Behrens on FLASH Anaconda Packages and Repositories, 2019-02-11 | ||
209 | * [[attach:conda_on_jupyterhub.pdf]]: Christopher Behrens on Conda Packages with Jupyterhub, 2019-04-xx | ||
210 | |||
211 |