search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

Python機器學習自學/自修 整理[00001] ~安裝開發環境 – jashliao部落格

Python機器學習自學/自修 整理[00001] ~安裝開發環境


01.在WINDOWS下安裝Python3.8[Anaconda x32]

    URL: https://www.anaconda.com/products/individual


02.測試開發環境
    開啟Spyder (Anaconda3)

	import sys

	print(sys.version_info)
	print(sys.version)
	print('hello, world!')
	print("你好, 世界!")
			
	#runfile('C:/Users/jashliao/.spyder-py3/temp.py', wdir='C:/Users/jashliao/.spyder-py3')
	#sys.version_info(major=3, minor=8, micro=3, releaselevel='final', serial=0)
	#3.8.3 (default, Jul  2 2020, 17:28:51) [MSC v.1916 32 bit (Intel)]
	#hello, world!
	#你好, 世界!


03.修正Spyder無法繪圖的錯誤
    提示訊息如下:「Figures now render in the Plots pane by default. To make them also appear inline in the Console, uncheck “Mute Inline Plotting” under the Plots pane options menu. 」
    想要弹出窗口显示matplotlib画的图片,修改设置:

        『Tools > Preferences > iPython console > Graphics > Graphics backend > Automatic』
        重启IDE,现在画图就会弹出窗口显示了。

	import numpy as np
	import matplotlib.pyplot as pt
	
	x = np.arange(0 , 360)
	y = np.sin( x * np.pi / 180.0)
	pt.plot(x,y)
	pt.xlim(0,360)
	pt.ylim(-1.2,1.2)
	pt.title("SIN function")
	pt.show()


04.Windows下anaconda安裝第三方包的方法小結(tensorflow、gensim為例)
    開始 > 所有程式 > anaconda >anaconda prompt
        第一種方法
            pip install gensim

        第二種方法是從官網下載支援window系統的三方包點選開啟連結
            pip install 路徑+whl檔名

        第三種是輸入

            conda install tensorflow


05.打包成EXE
    開始 > 所有程式 > anaconda >anaconda prompt
        安裝打包工具:
            pip install pyinstaller
        建立EXE

            pyinstaller C:\Users\jashliao\Desktop\temp.py –onefile [–noconsole]

    

PS.使用pyinstaller打包python程式時,出現如下Error訊息,UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb5 in position 152: invalid start byte

檔案位置:
    C:\ProgramData\Anaconda3\Lib\site-packages\PyInstaller\compat.py

找到 out = out.decode(encoding) 這一行

修改成 out = out.decode(encoding,”replace”)   



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦