[ Python ] 현재 Jupyter notebook의 Python Path는?

2020. 2. 8. 20:35분석 Python/구현 및 자료

728x90

현재 주피터 노트북의 환경 변수가 먼지 알고 싶을 때 anaconda를 사용할 경우 환경 변수가 여러 개라서 알기가 어렵다.
사소한 것이지만, 찾는데 시간이 걸렸으므로 블로그에 올려놓겠다.
추가적으로 해당 환경 변수에서 파이썬 script를 병렬로 돌리는 코드를 추가하였다.

import os
import sys

files =['uci_creditcard-train-0.2-0.0.csv',
 'uci_creditcard-train-0.4-0.0.csv',
 'uci_creditcard-train-0.5-0.0.csv',
 'uci_creditcard-train-0.1-0.0.csv',
 'uci_creditcard-train-0.3-0.0.csv']
scripts = [] 
for idx , i in enumerate(files) :
    if idx % 2 == 0 :
        gpu_n = 0
    else : 
        gpu_n = 1
    m = f"{condapath} {os.getcwd()}/run.py --batch_size 1000 --gpu {gpu_n} --filename {i}" 
    print(m)
    scripts.append(m)
#scripts

import os , re , time 
import numpy as np 
from multiprocessing import Pool  
def main(i) : 
    os.system("{}".format(scripts[i]))
if __name__ == '__main__': 
    pool = Pool(len(scripts)) 
    # pool = Pool()  would use the number of available processors instead 
    pool.map(main, 
             np.arange(len(scripts)).tolist()) 
    pool.close() 
    pool.join()

import numpy as np 
from multiprocessing import Pool  
def main(i) : 
    os.system("{}".format(scripts[i]))
if __name__ == '__main__': 
    pool = Pool(len(scripts)) 
    # pool = Pool()  would use the number of available processors instead 
    pool.map(main, 
             np.arange(len(scripts)).tolist()) 
    pool.close() 
    pool.join()

728x90