# **How to install gurobi python and get academic licence (Windows)**
## **`Install gurobi & get license`**
### 1. Log in with your academy email (https://www.gurobi.com/downloads/) and download Gurobi Optimizer.

### `Chose the corresponding version`


### 2. Access the licence (Academy)
Use the academic License:


copy your key (in this example is " grbgetkey 53f2fe08-fade-11eb-8a57-0242ac130004 ")
## **`Activate Gurobi`**
### 1. Open Your cmd or WSL, and paste your Gurobi licence key
```bash
grbgetkey 53f2fe08-fade-11eb-8a57-0242ac130004
```

copy the file path "C:\Users\USER\y\gurobi.lic"
> If it shows the message "Unable to contact key server", it means failure of activation. You should redo the previous steps.
### 2. Setting Environment Variable

Windows —> Setting —> About —>Advance system setting —> Environment variable

System Variable —> add a system variable with name "GRB_LICENSE_FILE" and value "C:\Users\USER\y\gurobi.lic" (your file path).

Paste "the file path "C:\Users\USER\y\gurobi.lic" on variable value.
## `Install Gurobi into python library`
- **Open terminal in the file which is installed `Gurobi`**


Input the command :
```basic
python setup.py install
```
---
## `Test in python`
```python
from gurobipy import *
```
---
## `Reference`
[如何在python中安装Gurobi(详细教程)_Book-bei的博客-CSDN博客_gurobi python](https://blog.csdn.net/weixin_41596280/article/details/89112302)
[Python - gurobi](https://www.gurobi.com/documentation/9.1/quickstart_mac/cs_python.html)
[The optimization model](https://www.gurobi.com/documentation/9.1/quickstart_mac/the_optimization_model.html)
[Simple Python Example](https://www.gurobi.com/documentation/9.1/quickstart_mac/cs_simple_python_example.html)
[My notion version](https://irradiated-drizzle-6f2.notion.site/How-to-install-gurobi-python-and-get-academic-licence-Windows-c69b9495af664dc4ae8f7dffdfaca163)