|
1 |
| -We recommend the use of Windows Subsystem for Linux (WSL) to install PyBaMM, see the |
2 |
| -instructions below to get PyBaMM working using Windows, WSL and VSCode. |
| 1 | +## Prerequisites |
3 | 2 |
|
4 |
| -## Install WSL |
| 3 | +To use and/or contribute to PyBaMM, you must have Python 3.6 or 3.7 installed (note that 3.8 is not yet supported). |
5 | 4 |
|
6 |
| -Follow the instructions from Microsoft |
7 |
| -[here](https://docs.microsoft.com/en-us/windows/wsl/install-win10). When given the |
8 |
| -option, choose the Ubuntu 18.04 LTS distribution to install. Don't forget to initialise |
9 |
| -the Ubuntu installation using the instructions given |
10 |
| -[here](https://docs.microsoft.com/en-us/windows/wsl/initialize-distro). |
| 5 | +To install Python 3 download the installation files from [Python's website](https://www.python.org/downloads/windows/). Make sure |
| 6 | +to tick the box on `Add Python 3.X to PATH`. For more detailed instructions please see the |
| 7 | +[official Python on Windows guide](https://docs.python.org/3.7/using/windows.html). |
11 | 8 |
|
12 | 9 | ## Install PyBaMM
|
13 | 10 |
|
14 |
| -Open a terminal window in your installed Ubuntu distribution by selecting "Ubuntu" from |
15 |
| -the start menu. This should give you a bash prompt in your home directory. |
| 11 | +### User install |
| 12 | +Launch the Command Prompt and go to the directory where you want to install PyBaMM. You can find a reminder of how to |
| 13 | +navigate the terminal [here](http://www.cs.columbia.edu/~sedwards/classes/2015/1102-fall/Command%20Prompt%20Cheatsheet.pdf). |
16 | 14 |
|
17 |
| -To download the PyBaMM source code, you first need to install git, which you can do by |
18 |
| -typing |
| 15 | +We recommend to install PyBaMM within a virtual environment, in order not |
| 16 | +to alter any distribution python files. |
19 | 17 |
|
20 |
| -```bash |
21 |
| -sudo apt install git-core |
22 |
| -``` |
23 |
| - |
24 |
| -For easier integration with WSL, we recommend that you install PyBaMM in your *Windows* |
25 |
| -Documents folder, for example by first navigating to |
| 18 | +To create a virtual environment `env` within your current directory type: |
26 | 19 |
|
27 | 20 | ```bash
|
28 |
| -$ cd /mnt/c/Users/USER_NAME/Documents |
| 21 | +python -m venv env |
29 | 22 | ```
|
30 |
| - |
31 |
| -where USER_NAME is your username. Exact path to Windows documents may vary. Now use git to clone the PyBaMM repository: |
| 23 | +You can then "activate" the environment using: |
32 | 24 |
|
33 | 25 | ```bash
|
34 |
| -git clone https://github.com/pybamm-team/PyBaMM.git |
| 26 | +env\Scripts\activate.bat |
35 | 27 | ```
|
| 28 | +Now all the calls to pip described below will install PyBaMM and its dependencies into |
| 29 | +the environment `env`. When you are ready to exit the environment and go back to your |
| 30 | +original system, just type: |
36 | 31 |
|
37 |
| -This will create a new directly called `PyBaMM`, you can move to this directory in bash |
38 |
| -using the `cd` command: |
39 |
| - |
40 |
| -```bash |
41 |
| -cd PyBaMM |
| 32 | +```bash |
| 33 | +deactivate |
42 | 34 | ```
|
43 | 35 |
|
44 |
| -If you are unfamiliar with the linux command line, you might find it useful to work through this |
45 |
| -[tutorial](https://tutorials.ubuntu.com/tutorial/command-line-for-beginners) provided by Ubuntu. |
46 |
| - |
47 |
| -Now head over and follow the installation instructions for PyBaMM for linux |
48 |
| -[here](INSTALL-LINUX-MAC.md). |
49 |
| - |
50 |
| -## Use Visual Studio Code to run PyBaMM |
51 |
| - |
52 |
| -You will probably want to use a native Windows IDE such as Visual Studio Code or the |
53 |
| -full Microsoft Visual Studio IDE. Both of these packages can connect to WSL so that you |
54 |
| -can write python code in a native windows environment, while at the same time using WSL |
55 |
| -to run the code using your installed Ubuntu distribution. The following instructions |
56 |
| -assume that you are using Visual Studio Code. |
57 |
| - |
58 |
| -First, setup VSCode to run within the `PyBaMM` directory that you created above, using |
59 |
| -the instructions provided [here](https://code.visualstudio.com/docs/remote/wsl). |
60 |
| - |
61 |
| -Once you have opened the `PyBaMM` folder in vscode, use the `Extensions` panel to |
62 |
| -install the `Python` extension from Microsoft. Note that extensions are either installed |
63 |
| -on the Windows (Local) or on in WSL (WSL:Ubuntu), so even if you have used VSCode |
64 |
| -previously with the Python extension, you probably haven't installed it in WSL. Make |
65 |
| -sure to reload after installing the Python extension so that it is available. |
| 36 | +PyBaMM can be installed via pip: |
| 37 | +```bash |
| 38 | +pip install pybamm |
| 39 | +``` |
66 | 40 |
|
67 |
| -If you have installed PyBaMM into the virtual environment `env` as in the PyBaMM linux |
68 |
| -install guide, then VSCode should automatically start using this environment and you |
69 |
| -should see something similar to "Python 3.6.8 64-bit ('env': venv)" in the bottom bar. |
| 41 | +PyBaMM's dependencies (such as `numpy`, `scipy`, etc) will be installed automatically when you install PyBaMM using `pip`. |
70 | 42 |
|
71 |
| -To test that vscode can run a PyBaMM script, navigate to the `examples/scripts` folder |
72 |
| -and right click on the `create-model.py` script. Select "Run current file in Python |
73 |
| -Interactive Window". This should run the script, which sets up and solves a model of SEI |
74 |
| -thickness using PyBaMM. You should see a plot of SEI thickness versus time pop up in the |
75 |
| -interactive window. |
| 43 | +For an introduction to virtual environments, see (https://realpython.com/python-virtual-environments-a-primer/). |
76 | 44 |
|
77 |
| -The Python Interactive Window in VSCode can be used to view plots, but is restricted in |
78 |
| -functionality and cannot, for example, launch separate windows to show plot. To setup an |
79 |
| -xserver on windows and use this to launch windows for plotting, follow these |
80 |
| -instructions: |
| 45 | +## Uninstall PyBaMM |
| 46 | +PyBaMM can be uninstalled by running |
| 47 | +```bash |
| 48 | +pip uninstall pybamm |
| 49 | +``` |
| 50 | +in your virtual environment. |
81 | 51 |
|
82 |
| -1. Install VcXsrv from [here](https://sourceforge.net/projects/vcxsrv/). |
83 |
| -1. Set the display port in the WSL command-line: `echo "export DISPLAY=localhost:0.0" >> |
84 |
| - ~/.bashrc` |
85 |
| -1. Install python3-tk in WSL: `sudo apt-get install python3-tk` |
86 |
| -1. Set the matplotlib backend to TKAgg in WSL: `echo "backend : TKAgg" >> |
87 |
| - ~/.config/matplotlib/matplotlibrc` |
88 |
| -1. Before running the code, just launch XLaunch (with the default settings) from within |
89 |
| - Windows. Then the code works as usual. |
| 52 | +## Installation using WSL |
| 53 | +If you want to install the optional PyBaMM solvers, you have to use the Windows Subsystem for Linux (WSL). You can find |
| 54 | +the installation instructions [here](INSTALL-WINDOWS-WSL.md). |
0 commit comments