Adding python modules to pydev in eclipse results in import error?

前端 未结 11 2135
难免孤独
难免孤独 2020-12-14 03:01

I have a problem getting PyDev on eclipse to recognize already installed modules. Here is my detailed approach. The machine is a Mac (Snow Leopard).

In terminal the

11条回答
  •  忘掉有多难
    2020-12-14 03:28

    I ran into the same problem just today. I am using pydev and had a working project with a number of sub-packages. Suddenly after having created a new module I was not able to use this module in a different package. The puzzling feature was that I could use another module in the same sub-package...

    Finally after

    1. eclipse restart
    2. remove/add python interpreter and all site-packages
    3. annoyed head-scratching

    I deleted all compiled classes with the following script:

    import os
    
    def clean_folder(folder):
      for file in os.listdir(folder):
        path = os.path.join(folder,file)
        if os.path.isdir(path):
            clean_folder(path)
    
        if '.pyc' == file[-4:]:
            print 'deleting: ' + str(path)
            os.remove(path)
    
    if __name__ == '__main__':
      folder = 'YOUR_PROJECT_SRC_PATH'
      clean_folder(folder)
    

    and finally I can do 'actual' work :) Hope it helps somebody...

提交回复
热议问题