You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "Install new Python packages on SQL Server | Microsoft Docs"
3
+
ms.date: "01/04/2018"
4
+
ms.reviewer:
5
+
ms.suite: sql
6
+
ms.prod: machine-learning-services
7
+
ms.prod_service: machine-learning-services
8
+
ms.component: python
9
+
ms.technology:
10
+
- "r-services"
11
+
ms.tgt_pltfrm: ""
12
+
ms.topic: "article"
13
+
ms.assetid: 21456462-e58a-44c3-9d3a-68b4263575d7
14
+
caps.latest.revision: 1
15
+
author: "jeannt"
16
+
ms.author: "jeannt"
17
+
manager: "cgronlund"
18
+
ms.workload: "On Demand"
19
+
---
20
+
# Install new Python packages on SQL Server
21
+
22
+
This article describes how to install new Python packages on an instance of SQL Server 2017.
23
+
24
+
It also describes how to list packages that are installed in the current environment.
25
+
26
+
## Prerequisites
27
+
28
+
The process for installing new packages is much like that in a standard Python environment. However, some additional steps are required if the server does not have an internet connection.
29
+
30
+
+ You must have installed Machine Learning Services (In-Database) with the Python language option. For instructions, see [Set up Python Machine Learning Services](setup-python-machine-learning-services.md).
31
+
32
+
+ For each server instance, you must install a separate copy of the package. Packages cannot be shared across instances.
33
+
34
+
+ Determine whether the package you intend to use will work with Python 3.5 and in the Windows environment.
35
+
36
+
In general, there are few limitations on the packages that you can import and use in the SQL Server environment. Possible problems include packages that use networking functionality that is blocked on the server or by the firewall, or packages with dependencies that cannot be installed on a Windows computer.
37
+
38
+
+ Administrative access to the server is required to install packages.
39
+
40
+
## Add a new Python package
41
+
42
+
For this example, we assume that you want to install a new package directly on the SQL Server computer.
43
+
44
+
The package installed in this example is [CNTK](https://docs.microsoft.com/cognitive-toolkit/), a framework for deep learning from Microsoft that supports customization, training, and sharing of different types of neural networks.
45
+
46
+
> [!TIP]
47
+
> Need help configuring your Python tools? See these blogs:
48
+
>
49
+
> [Getting Started with Python Web Services using Machine Learning Server](https://blogs.msdn.microsoft.com/mlserver/2017/12/13/getting-started-with-python-web-services-using-machine-learning-server/)
50
+
>
51
+
> [David Crook: Microsoft Cognitive Toolkit + VS Code](http://dacrook.com/cntk-vs-code-awesome/)
52
+
53
+
### Step 1. Download the Windows version of the Python package
54
+
55
+
+ If you are installing Python packages on a server with no internet access, you must download the WHL file to a different computer and then copy it to the server.
56
+
57
+
For example, on a separate computer, you can download the WHL file from this site [https://cntk.ai/PythonWheel/CPU-Only](https://cntk.ai/PythonWheel/CPU-Only/cntk-2.1-cp35-cp35m-win_amd64.whl), and then copy the file `cntk-2.1-cp35-cp35m-win_amd64.whl` to a local folder on the SQL Server computer.
58
+
59
+
+ SQL Server 2017 uses Python 3.5. Be sure to get the Windows version of the package, and a version that is compatible with Python 3.5.
60
+
61
+
This page contains downloads for multiple platforms and for multiple Python versions: [Set up CNTK](https://docs.microsoft.com/cognitive-toolkit/Setup-CNTK-on-your-machine)
62
+
63
+
### Step 2. Open a Python command prompt
64
+
65
+
Locate the default Python library location used by SQL Server. If you have installed multiple instances, be sure to locate the PYTHON_SERVICE folder for the instance where you want to add the package.
66
+
67
+
For example, if Machine Learning Services has been installed using defaults, and machine learning is enabled on the default instance, the path would be as follows:
Open the Python command prompt associated with the instance.
72
+
73
+
> [!TIP]
74
+
> We recommend that you set up a Python environment specific to Machine Learning Server or SQL Server.
75
+
76
+
### Step 3. Install the package using pip
77
+
78
+
+ If you are accustomed to using the Python command line, use PIP.exe to install new packages. You can find the **pip** installer in the `Scripts` subfolder.
79
+
80
+
If you get an error that **pip** is not recognized as an internal or external command, you can add the path of the Python executable and the Python scripts folder to the PATH variable in Windows.
81
+
82
+
The full path of the **Scripts** folder in a default installation is as follows:
+ If you are using Visual Studio 2017, or Visual Studio 2015 with the Python extensions, you can run `pip install` from the **Python Environments** window. Click **Packages**, and in the text box, provide the name or location of the package to install. You don't need to type `pip install`; it is filled in for you automatically.
87
+
88
+
- If the computer has Internet access, provide the name of the package, or the URL of a specific package and version. For example, to install the version of CNTK that is supported for Windows and Python 3.5, you coudl specify the download URL: `https://cntk.ai/PythonWheel/CPU-Only/cntk-2.1-cp35-cp35m-win_amd64.whl`
89
+
90
+
- If the computer does not have internet access, you should have downloaded the WHL file in advance. Then, specify the local file path and name. For example, paste the following path and file to install the WHL file downloaded from the site:
### Step 4. Load the package or its functions as part of your script
110
+
111
+
When installation is complete, you can immediately begin using the package as described in the next step.
112
+
113
+
For examples of deep learning using CNTK, see these tutorials: [Python API for CNTK](https://cntk.ai/pythondocs/tutorials.html)
114
+
115
+
To use functions from the package in your script, insert the standard `import <package_name>` statement in the initial lines of the script:
116
+
117
+
```python
118
+
import numpy as np
119
+
import cntk as cntk
120
+
cntk._version_
121
+
```
122
+
123
+
## How to view installed packages using conda
124
+
125
+
There are different ways that you can get a list of installed packages. For example, you can view the installed packages in the **Python Environments** windows of Visual Studio.
126
+
127
+
If you are using the Python command line, you can use the **conda** package manager, which is included with the Anaconda Python environment added by SQL Server setup.
128
+
129
+
To view Python packages that have been installed in the current environment, run this command from the command prompt windows:
130
+
131
+
```python
132
+
conda list
133
+
```
134
+
135
+
For more information about **conda** and how you can use it to create and manage multiple Python environments, see [Managing environments with conda](https://conda.io/docs/user-guide/tasks/manage-environments.html).
Copy file name to clipboardExpand all lines: docs/advanced-analytics/r/create-a-local-package-repository-using-minicran.md
+30-23Lines changed: 30 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Create a local package repository using miniCRAN | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "09/29/2017"
4
+
ms.date: "01/04/2018"
5
5
ms.reviewer:
6
6
ms.suite: sql
7
7
ms.prod: machine-learning-services
@@ -30,7 +30,12 @@ There are two ways that you can prepare R packages for installation onto a serve
30
30
31
31
-[Manually download and copy packages one by one](#bkmk_manual)
32
32
33
-
This article describes how you can create an R package repository using both methods, and recommends use of the **miniCRAN** package.
33
+
You can find the list of dependent packages in the DESCRIPTION file for the downloaded package.
34
+
35
+
However, packages listed in **Imports** might have second-level dependencies. For this reason, we recommend use of the **miniCRAN** method.
36
+
37
+
> [!TIP]
38
+
> Did you know that you can use miniCRAN to prepare packages for use in Azure Machine Learning? For more information, see this blog: [Using miniCRAN in Azure ML, by Michele Usuelli](https://www.r-bloggers.com/using-minicran-in-azure-ml/)
34
39
35
40
## Prepare packages using miniCRAN
36
41
@@ -48,6 +53,9 @@ There are many advantages to using miniCRAN to create the repository:
48
53
49
54
After creating the repository, you can modify it by adding new packages or upgrading the version of existing packages.
50
55
56
+
> [!NOTE]
57
+
> The miniCRAN package itself is dependent on 18 other CRAN packages, among which is the RCurl package, which has a system dependency on the curl-devel package. Similarly, package XML has a dependency on libxml2-devel. We recommend, therefore, that you build your local repository initially on a machine with full Internet access, so that you can easily satisfy all these dependencies. After created, you can move the repository to a different location.
58
+
51
59
### Step 1. Install the miniCRAN package
52
60
53
61
You begin by creating a miniCRAN repository to use as a source. You should create this repository on a computer that has internet access.
@@ -67,9 +75,11 @@ You begin by creating a miniCRAN repository to use as a source. You should creat
2.Indicatealocalfolderinwhichtostorethecollectedpackages.Youneedn't name the folder miniCRAN; it could be a more descriptive name like "GeneticsPackages" or "ClientRPackages1.0.2".
Do not add dependencies to this initial list; the **igraph** package used by miniCRAN generates the list of dependencies for you. For more information about how to use this graph, see [Using miniCRAN to identify package
94
+
Donotadddependenciestothisinitiallist; the**igraph**packageusedbyminiCRANgeneratesthelistofdependenciesforyou.Formoreinformationabouthowtousethegenerateddependencygraph, see [UsingminiCRANtoidentifypackage
- Upload packages to a SQL database and install packages on a per-database basis, using the CREATE EXTERNAL LIBRARY statement. See [Install additional R packages on SQL Server](install-additional-r-packages-on-sql-server.md).
0 commit comments