简体   繁体   English

在Eclipse PyDev中刷新软件包项目

[英]Refreshing a package project in Eclipse PyDev

I have a PyDev project that is organized like this (I have omitted the .git directory). 我有一个这样组织的PyDev项目(我省略了.git目录)。 The aim is to build a package called stattests . 目的是构建一个名为stattests的软件包。

    |   .gitignore
    |   .project
    |   .pydevproject
    |   
    +---.git
    +---stattests
    |   |   setup.py
    |   |   
    |   +---tests
    |   |   |   tests.py
    |   |   |   __init__.py
    |           
    \---unittests
            tests1.py

The top level directory stattests contains the setup.py file, and the sub-folder tests , a module that contains an __init__.py which imports all the functions from tests.py in the same module folder. 顶级目录stattests包含setup.py文件,以及子文件夹tests ,该模块包含__init__.py的模块,该模块将tests.py中的所有功能tests.py同一模块文件夹中。 Note that tests here are not unit tests, but statistical tests. 注意这里的测试不是单元测试,而是统计测试。

Unit tests are contained in the unittests folder, and the which looks like this: 单元测试包含在unittests文件夹中,其外观如下所示:

# unittests/tests1.py
from stattests.tests import tests
series1 = pd.Series(np.random.randn(10))
tests.test1(series1)

When I execute this testing script it does not refresh the definition of the stattests.tests.test1 function, and uses an old definition instead. 当我执行此测试脚本时,它不会刷新stattests.tests.test1函数的定义,而是使用旧的定义。

I have also manually added all the folder and subfolders of the project to the project PYTHONPATH property. 我还手动将项目的所有文件夹和子文件夹添加到项目PYTHONPATH属性。

Help appreciated. 帮助表示赞赏。

Do you have: 'User Module Deleter (UMD)' (preferences > pydev > interactive console > user module deleter) > enable UMD activated? 您是否具有“用户模块删除器(UMD)”(首选项> pydev>交互式控制台>用户模块删除器)>启用了UMD?

Ie: If you are only sending it to the console modules are cached in sys.module, so, imported modules aren't usually re-evaluated... now, UMD, if enabled, tries to force those to reload by using 'runfile' instead of 'execfile) -- although this can be sometimes tricky, so, it may fail too -- so, if you want to do a simple run, the recommended way is running with F9 (run current module), and Ctrl+Alt+Enter is recommended if you want to use the symbols defined afterwards interactively in the shell. 即:如果您仅将其发送到控制台,则模块将被缓存在sys.module中,因此,通常不会重新评估导入的模块...现在,UMD(如果启用)会尝试使用“ runfile”来强制重新加载这些模块。 '而不是'execfile)-尽管有时可能很棘手,所以它也可能会失败-因此,如果要进行简单的运行,建议的方法是使用F9(运行当前模块)和Ctrl +如果要在外壳中交互使用以后定义的符号,建议使用Alt + Enter。

If it isn't updating then you can clear the cache and make sure you edited and saved the right file. 如果未更新,则可以清除缓存并确保已编辑并保存了正确的文件。 In the project structure there should be a folder called pycache just delete it. 在项目结构中,应该有一个名为pycache的文件夹,只需将其删除即可。 Another way to refresh in eclipse is to right click > refresh on the project in the PyDevPackage Explorer or press F5. 在Eclipse中刷新的另一种方法是右键单击>在PyDevPackage Explorer中刷新项目,或按F5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM