1. Python 是如何去找module 位置調用object / function

    1. python 會自動生成list 收集路徑
      1. import sys → print(sys.path)
  2. 如果我要讓module 讓team member 可用我要放在什麼路徑讓大家可以調用

    1. python 安裝主路徑 (sys.path) _可以把module 放在sys.path
      1. we can put  our modules in C:/somepathhere/anaconda/lib/pythonX.X/site-packages since it’s always on sys.path .
    2. 放在main program (缺點: 其它程式無法使用)
    3. 更改路徑到 sys.path 可以抓的到有
      1. use sys.path.append() method (非長久之計)

        import sys 
        sys.path.append ("C:/whatever path)  
        # 不建議 因為如果有改動的話,就要再改path 
        
      2. Change the PYTHONPATH environment variable 利用環境變數

      3. Go to anywhere in sys.path and create a sitecustomize.py in that directory

        import site
        site.addsitedir (" C:\\\\users\\anaconda3\\site-packages\\win64")
        

Untitled

Untitled