2019年7月26日 星期五

Set up python development environment 設定Python開發環境

Set up python development environment 設定Python開發環境

1.安裝Visual Studio或Visual Studio Core

or

2.安裝Python


3.確認Python安裝成功

4.啟動Visual Studio Core,安裝Python extension

5.選取 [Python 解譯器]
opening the Command Palette (Ctrl+Shift+P), start typing the command Python: Select Interpreter to search, then select the command

6.第一次啟動Python: Select Interpreter需要一些時間偵測此台主機已安裝的Python環境

7.選擇Python環境

https://code.visualstudio.com/docs/python/environments

8.在VS Code 終端機執行Python程式
   啟動終端機方法1,Terminal > New Terminal
    啟動終端機方法2,View > Terminal

9.若出現無法辨識conda命令
   輸入python若出現無法辨識python命令


    解決方法: 設定環境變數,在Path變數加入以下兩個路徑
    C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts
    C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64
 
    正常啟動終端機的畫面如下

10.執行python,進入Python環境
     輸入印出Hello world的Python程式碼 print("Hello World")

11.測試執行python script檔
   新增一個py檔,並輸入以下Python script
   msg = "Hello World"
   print(msg)
   儲存後,按右鍵選擇[ Run Python File in Terminal]
 
    執行結果如下


SQL Server Machine Learning - Python client:

1.下載PowerShell script安裝Python for SQL Server Machine Learning Service/Server
https://aka.ms/mls93-py
or
https://aka.ms/mls-py

The script installs Anaconda 4.2.0, which includes Python 3.5.2, along with all packages listed previously.
Microsoft Python packages common to both client and server systems include the following:

  • revoscalepy
  • microsoftml
  • azureml-model-management-sdk
  • pre-trained models

This article describes how to install a Python interpreter (Anaconda) and Microsoft's Python packages locally on a client machine. Once installed, you can use all of the Python modules in Anaconda, Microsoft's packages, and any third-party packages that are Python 3.5 compliant. For remote compute context, you can only call the Python functions from packages in the above list.



2.若沒有指定安裝路徑,預設安裝在 C:\ProgramFiles\Microsoft\PyForMLS


3.設定環境Path變數
C:\Program Files\Microsoft\PyForMLS


4.IDE開發工具才能偵測到安裝號的Python環境
    Visual Studio Code

    Visual Studio須自訂這個新的Python環境


Reference:
 Get started using Python on Windows for beginners
 https://docs.microsoft.com/en-us/windows/python/get-started/python-for-education
 Getting Started with Python in VS Code
 https://code.visualstudio.com/docs/python/python-tutorial
 How to install Python client libraries for remote access to a Machine Learning Server
 https://docs.microsoft.com/en-us/machine-learning-server/install/python-libraries-interpreter

沒有留言:

Azure API Management

Azure API Management