程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

How to debug Python programs running with command line parameters in pycharm

編輯:Python

One 、 Click on Run--->Edit Configuration---> Select the program you want to run with the command line arguments , stay parameters Enter command line parameters in .

https://blog.csdn.net/weixin_44457930/article/details/120572174

Two 、 Use the environment variables that need to be used os.environ Add to .py In the code file .

The following Command line utilize export Set the environment variable

export MASTER_ADDR=localhost
export MASTER_PORT=5678

Rewrite as follows with os.environ Set the environment variable

import os
os.environ['MASTER_ADDR'] = 'localhost'
os.environ['MASTER_PORT'] = '5678'

Otherwise, an error will be reported :ValueError: Error initializing torch.distributed using env:// rendezvous: environment variable MASTER_ADDR( Or others ) expected, but not set

https://blog.csdn.net/weixin_41529093/article/details/123704238


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved