首页 > 解决方案 > 如何摆脱 PyCharm 中的库根标记

问题描述

我已经开始使用 Pyramid 应用程序,它需要setup.py使用,但是一旦我构建了应用程序,我的app文件夹就被标记为library root

这不方便,因为当我打开一个文件时,它也在External Libraries下打开它展开它。这可以通过取消选中Always Select Opened File来“修复” ,但我喜欢这个功能,所以我不想禁用它。

我也尝试在设置中调整项目结构,但没有帮助。

如何摆脱这个 _library_root_ 标记?

例子

UPD。内容setup.py

setup(
    name='app',
    version=0.1,
    description='Blog with CMS',
    classifiers=[
      "Programming Language :: Python",
      "Framework :: Pylons",
      "Topic :: Internet :: WWW/HTTP",
      "Topic :: Internet :: WWW/HTTP :: WSGI :: Application"
    ],
    keywords="web services",
    author='',
    author_email='',
    url='',
    packages=find_packages(),
    include_package_data=True,
    zip_safe=False,
    install_requires=['cornice', 'waitress'],
    entry_points="""\
    [paste.app_factory]
    main=app:main
    """,
    paster_plugins=['pyramid']
)

标签: pythonpycharmsetuptoolspyramid

解决方案


发生这种情况的原因是 PyCharm 会添加sd-blog/app到解释器路径pip install -e中,以便能够为app对象提供补全。可能的解决方法:

  1. app从解释器路径中删除

  2. 标记sd-blog/app为源根目录以恢复在步骤 1 中损坏的代码洞察力


推荐阅读