PyCharm,无法导入模块

时间:2017-12-01 19:20:13

标签: python pycharm

我需要导入

function my_portfolio() {

  // Set the labels, this variable is used in the $args array
  $labels = array(
    'name'               => __( 'Projects' ),
    'singular_name'      => __( 'Project' ),
    'add_new'            => __( 'Add New Project' ),
    'add_new_item'       => __( 'Add New Project' ),
    'edit_item'          => __( 'Edit Project' ),
    'new_item'           => __( 'New Project' ),
    'all_items'          => __( 'All Projects' ),
    'view_item'          => __( 'View Project' ),
    'search_items'       => __( 'Search Project' ),
    'featured_image'     => 'Preview',
    'set_featured_image' => 'Add Preview'
  );

  // The arguments for our post type, to be entered as parameter 2 of register_post_type()
  $args = array(
    'labels'            => $labels,
    'description'       => 'Holds portfolio specific data',
    'public'            => true,
    'menu_position'     => 25,
    'supports'          => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields' ),
    'has_archive'       => true,
    'show_in_admin_bar' => true,
    'show_in_nav_menus' => true,
    'has_archive' => 'page template',
    'rewrite'           => true,
    'query_var'         => 'project'
  );

  // Call the actual WordPress function
  // Parameter 1 is a name for the post type
  // Parameter 2 is the $args array
  register_post_type( 'project', $args);
}

模块到最新的1.yaml 2.pypiper IDE。我在可用模块列表中找不到PyCharm。当我尝试为pypiper添加新的存储库时:

https://github.com/epigen/pypiper.git

仍然相同:在搜索字段中输入pypiper不会产生任何结果。

同时可以找到

pypiper,但是当我尝试添加它时,它会给我一个错误:

yaml

1 个答案:

答案 0 :(得分:0)

PyCharm在存储库中查找已被告知要查看的包。默认情况下,它会查看https://pypi.python.org/simple

实际上,这意味着如果您无法通过pip安装某些内容,则无法通过PyCharm界面进行安装。

你需要做的是弄明白:

  1. How to install yaml
  2. sudo pip install pyyaml

    1. How to install pypiper
    2. pip install --user https://github.com/epigen/pypiper/zipball/master

      当我遇到这些问题时,我最简单的方法就是安装在与PyCharm相对的命令行上,除非它是虚拟环境。只需确保您的pip引用您在PyCharm中使用的同一个python解释器,否则您仍然无法在PyCharm中看到它。