|
1 | 1 | --- |
2 | | -title: "Step 1: Configure pyodbc Python environment" |
3 | | -description: "Step 1 of this getting started guide involves installing Python, the Microsoft ODBC Driver for SQL Server, and pyODBC into your development environment." |
| 2 | +title: Step 1: Configure pyodbc environment |
| 3 | +description: Step 1 of this getting started guide involves installing Python, the Microsoft ODBC Driver for SQL Server, and pyODBC into your development environment. |
4 | 4 | author: David-Engel |
5 | 5 | ms.author: v-davidengel |
6 | | -ms.date: 04/17/2023 |
| 6 | +ms.date: 08/22/2023 |
7 | 7 | ms.service: sql |
8 | 8 | ms.subservice: connectivity |
9 | | -ms.topic: conceptual |
| 9 | +ms.topic: how-to |
| 10 | +# CustomerIntent: As a developer, I want to install the pymssql package so that I can connect to SQL with Python code. |
10 | 11 | --- |
| 12 | + |
11 | 13 | # Step 1: Configure development environment for pyodbc Python development |
12 | 14 |
|
13 | | -This article explains how to configure your development environment for pyodbc Python development. |
| 15 | +You need to configure your development environment with the prerequisites in order to develop an application using the pyodbc Python driver for SQL Server. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +- Python 3 |
| 20 | + - If you don't already have Python, install the **Python runtime** and **Python Package Index (PyPI) package manager** from [python.org](https://www.python.org/downloads/). |
| 21 | + - Prefer to not use your own environment? Open as a devcontainer using [GitHub Codespaces](https://github.com/features/codespaces). |
| 22 | + - [](https://codespaces.new/github/codespaces-blank?quickstart=1). |
| 23 | + |
| 24 | +## Install the ODBC driver |
| 25 | + |
| 26 | +This driver requires the host operating system to have the appropriate ODBC driver already installed. |
| 27 | + |
| 28 | +### [Windows](#tab/windows) |
| 29 | + |
| 30 | +1. Obtain and install the Microsoft ODBC driver for SQL Server on Windows: |
14 | 31 |
|
15 | | -## Windows |
| 32 | + - [Microsoft ODBC Driver for SQL Server on Windows](../../odbc/windows/system-requirements-installation-and-driver-files.md#installing-microsoft-odbc-driver-for-sql-server) |
16 | 33 |
|
17 | | -1. **Download Python installer**. If your machine doesn't have Python, install it. Go to the [**Python download page**](https://www.python.org/downloads/windows/) and download the appropriate installer. For example, if you are on a 64-bit machine, download the Python 3.10 (x64) installer. |
18 | | - |
19 | | -2. **Install Python**. Once the installer is downloaded, do the following steps: |
| 34 | +1. Verify that you have installed the driver. |
20 | 35 |
|
21 | | - 1. Double-click the file to start the installer. |
22 | | - 1. Select your language, and agree to the terms. |
23 | | - 1. Follow the instructions on the screen to install Python on your computer. |
24 | | - 1. You can verify that Python is installed by going to a command prompt and running `python -V`. You can also search for Python in the start menu. |
| 36 | +### [Linux](#tab/linux) |
25 | 37 |
|
26 | | -3. [**Install the Microsoft ODBC Driver for SQL Server on Windows**.](../../odbc/windows/system-requirements-installation-and-driver-files.md#installing-microsoft-odbc-driver-for-sql-server) |
27 | | - |
28 | | -4. **Open cmd.exe as an administrator**. |
| 38 | +1. Obtain and install the Microsoft ODBC driver for SQL Server on Linux: |
29 | 39 |
|
30 | | -5. **Install pyodbc using pip - Python package manager**. |
| 40 | + - [Microsoft ODBC driver for SQL Server (Linux)](../../odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server.md) |
31 | 41 |
|
32 | | - ```cmd |
33 | | - pip install pyodbc |
34 | | - ``` |
| 42 | +1. Verify that you have installed the driver. |
| 43 | + |
| 44 | +### [macOS](#tab/macos) |
| 45 | + |
| 46 | +1. Obtain and install the Microsoft ODBC driver for SQL Server on macOS: |
| 47 | + |
| 48 | + - [Microsoft ODBC driver for SQL Server (macOS)](../../odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos.md) |
| 49 | + |
| 50 | +1. Verify that you have installed the driver. |
| 51 | + |
| 52 | +--- |
35 | 53 |
|
36 | | -## Linux |
| 54 | +## Install the pyodbc package |
37 | 55 |
|
38 | | -Installing on Linux is similar. If the following instructions don't work, see the [pyODBC install instructions](https://github.com/mkleehammer/pyodbc/wiki/Install#installing-on-linux), which have more details for different Linux distributions. |
| 56 | +Get the [`pyodbc` package](https://pypi.org/project/pyodbc/) from PyPI. |
39 | 57 |
|
40 | | -1. **Open terminal**. |
| 58 | +1. Open a command prompt in an empty directory. |
41 | 59 |
|
42 | | -2. [**Install the Microsoft ODBC driver for SQL Server (Linux)**.](../../odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server.md) |
| 60 | +1. Install the [`pyodbc` package](https://pypi.org/project/pyodbc/). |
43 | 61 |
|
44 | | -3. **Install pyodbc**. |
| 62 | + ```bash |
| 63 | + pip install pyodbc |
| 64 | + ``` |
45 | 65 |
|
46 | | - ```bash |
47 | | - sudo -H pip install pyodbc |
48 | | - ``` |
| 66 | +## Check installed packages |
49 | 67 |
|
50 | | -## macOS |
| 68 | +You can use the PyPI command-line tool to verify that your intended packages are installed. |
51 | 69 |
|
52 | | -1. [**Install the Microsoft ODBC driver for SQL Server (macOS)**.](../../odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos.md) |
| 70 | +1. Check the list of installed packages with `pip list`. |
53 | 71 |
|
54 | | -2. **Install pyodbc** from a terminal using the [pyODBC install instructions](https://github.com/mkleehammer/pyodbc/wiki/Install#installing-on-macosx). |
| 72 | + ```bash |
| 73 | + pip list |
| 74 | + ``` |
55 | 75 |
|
56 | 76 | ## Next steps |
57 | 77 |
|
58 | | -[Create an SQL database for pyodbc](step-2-create-a-sql-database-for-pyodbc-python-development.md). |
| 78 | +> [!div class="nextstepaction"] |
| 79 | +> [Step 2: Create an SQL database for pyodbc Python development](step-2-create-a-sql-database-for-pyodbc-python-development.md) |
0 commit comments