forked from mahmoodlab/UNI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGETTING_STARTED copy.txt
272 lines (134 loc) · 5.56 KB
/
GETTING_STARTED copy.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
____Pip install current package to reflect edits immediately _____
Navigate to your package and use…
pip install -e .
__QUICK NOTES__
File>> open folder
Terminal>> new terminal
____ ____ ____ ____ ____ ____
sudo apt-get update
python3 -m venv .venv
source .venv/bin/activate
pip3 install --upgrade pip
pip3 install --upgrade setuptools
____ ____ ____ ____ ____ ____
local package to allow you to import and use it directly
pip install -e .
____ ____ ____ ____ ____ ____
setting up code runner to use virtual environment
see this link
Go to VS Code settings (File -> Preferences -> Settings or Cmd/Ctrl + ,).
In the top right corner of the settings tab, you'll see an {} icon which stands for "Edit in settings.json". Click on it.
Add or update the code-runner.executorMap setting to:
SEARCH FOR "code-runner.executorMap"
in settings, there will be many settings just search for python and replace as follows
"code-runner.executorMap": {
...
...
...
// "python": "python -u",
"python": "\"$pythonPath\" $fullFileName"
...
...
...
}
____ ____ ____ ____ ____ ____
enable tqdm to work in jupyter notebook, run the following in terminal venv then launch new kernel for jupyter notebook (i.e. "jupyter notebook" from terminal).
jupyter nbextension enable --py widgetsnbextension
____ ____ ____ ____ ____ ____
DEBUGGING
https://stackoverflow.com/questions/42609943/what-is-the-use-case-for-pip-install-e
once you have a setup.py file in root directory you can use this command to install package that automatically updates as you use it. this allows you to directly debug the code using hte debugger!!!!
pip install -e .
____ ____ ____ ____ ____ ____
SETTING AUTO ACTIVATE VENV
https://stackoverflow.com/questions/58433333/auto-activate-virtual-environment-in-visual-studio-code
This is how I did it in 2021:
Enter Ctrl+Shift+P in your vs code.
Locate your Virtual Environment:
Python: select interpreter > Enter interpreter path > Find
Once you locate your virtual env select your python version:
your-virtual-env > bin > python3.
Now in your project you will see .vscode directory created open settings.json inside of it and add:
"python.terminal.activateEnvironment": true
don't forget to add comma before to separate it with already present key value pair.
Now restart the terminal.
You should see your virtual environment activated automatically.
--auto open terminal in venv setting--
"python.terminal.activateEnvInCurrentTerminal": true
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
if you need to, install pipreqs, on your default python terminal
pip install pipreqs
then CD to your root directory
then run (use --force to force overwrite)
pipreqs .
Note this is just a quick initial fix and version issues may need to be considered later.
run unit tests if they exist.
pip3 install -r pip_start.txt # generic packages to quickly get started on a project
OR
pip3 install -r requirements.txt
pip install pipreqs # should already be installed on my mac
#then
pipreqs path/to/project
for example
(base) phil@Phillips-MacBook-Pro ~ % pipreqs /Users/phil/Dropbox/GITHUB/nillip/nillip
INFO: Successfully saved requirements file in /Users/phil/Dropbox/GITHUB/nillip/nillip/requirements.txt
now move it to the root folder /Users/phil/Dropbox/GITHUB/nillip/
__JUPYTER__
Must install ipython (see in pip_start.txt file) (ipykernel)
https://stackoverflow.com/questions/58119823/jupyter-notebooks-in-visual-studio-code-does-not-use-the-active-virtual-environm
STEP 1
pip install ipykernel
pip install notebook
You must RESTART VS Code after you pip install, specifically for 'ipykernel'.
But just always do it to be safe.
ALSO leave 'user' as 'user' and just change the project name
STEP 2
Then use
ipython kernel install --user --name=UNI
E.G. >>>ipython kernel install --user --name=notebook_poc
ipython kernel install --user --name=UNI
Where EXAMPLE_PROJECT_NAME is what you want to name it so make it match the name of your project
folder to stay organized. Note this is just a name and it will run whatever virtual
environment you run that line from.
This installs the venv onto jupyter, then you can type
jupyter notebook
Then select the environment you want to use with when creating a new .ipynb file.
UNINSTALL jupyter VENV
From a given venv type
jupyter kernelspec uninstall EXAMPLE_PROJECT_NAME
__PYTORCH__
Systems require different versions go here to check out what to download
https://pytorch.org/get-started/locally/
For my MBP 2015 it is
pip3 install torch torchvision torchaudio
__MISC__
set python default in mac
echo "alias python='/usr/local/bin/python3'" >> ~/.zshrc
source ~/.zshrc
____ ____ ____ ____ ____ ____
input doesnt stop in vscode
https://stackoverflow.com/questions/69186311/python-input-function-not-working-in-vs-code
Code Runner shows results in OUTPUT and doesn't accept inputs by default. Add
"code-runner.runInTerminal": true
in Settings.json, then you can input data.
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____
____ ____ ____ ____ ____ ____