測試環境 Windows 10
我這邊主要是透過 Gitlab 跑 CI ( Runner 為 Windwos + Powershell 跑 Python ) , 但一直跑出錯誤訊息.
Running with gitlab-runner 16.6.1 (f5da3c5a) on VM win10 XhxhUwtwA, system ID: s_6ce8c193f63e Preparing the "shell" executor 00:00 Using Shell (powershell) executor... Preparing environment 00:00 Running on DESKTOP-THOBKJO... Getting source from Git repository 00:03 Fetching changes with git depth set to 20... Reinitialized existing Git repository in C:/GitLab-Runner/builds/XhxhUwtwA/0/root/powershell_test/.git/ Checking out c393deb3 as detached HEAD (ref is main)... git-lfs/3.4.0 (GitHub; windows amd64; go 1.20.6; git d06d6e9e) Skipping Git submodules setup Executing "step_script" stage of the job script 00:01 $ py hello.py Ben py : �L�k���� 'py' ���J�O�_�� Cmdlet�B���ơB���O�ɩΥi�����{�����W�١C���ˬd�W�٫��r�O�_���T�A�p�G�]�t���|���ܡA�нT�{ ���|�O�_���T�A�M���A�դ@���C ���� �u��:254 �r��:1 + py hello.py Ben + ~~ + CategoryInfo : ObjectNotFound: (py:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ERROR: Job failed: exit status 1
後來才知道安裝 Python 在 Windows 下需要特別注意路徑問題,參考文章 – https://ithelp.ithome.com.tw/articles/10210071
安裝時須注意
- Python 官網下載 https://www.python.org/downloads/
- 選擇 Customize installation 並勾選 Add python.exe to PATH
- 都勾選
- 勾選 Installa Python 3.12 for all users 與 Associate files with Python ,並選擇自訂路徑 Customize install location 為 c:\Python312
環境變數設定
重新跑 CI ,就正常了.
Running with gitlab-runner 16.6.1 (f5da3c5a) on VM win10 XhxhUwtwA, system ID: s_6ce8c193f63e Preparing the "shell" executor 00:00 Using Shell (powershell) executor... Preparing environment 00:03 Running on DESKTOP-THOBKJO... Getting source from Git repository 00:04 Fetching changes with git depth set to 20... Reinitialized existing Git repository in C:/GitLab-Runner/builds/XhxhUwtwA/0/root/powershell_test/.git/ Checking out 9ab6f7c2 as detached HEAD (ref is main)... git-lfs/3.4.0 (GitHub; windows amd64; go 1.20.6; git d06d6e9e) Skipping Git submodules setup Executing "step_script" stage of the job script 00:01 $ python hello.py Ben Hello Ben Job succeeded
沒有解決問題,試試搜尋本站其他內容