简体   繁体   English

已经在 cmd 上安装了 package 那么它如何在 pycharm 上工作?

[英]Already Installed package on cmd then how it work on pycharm?

I want to install one package on cmd then it also work on pycharm. No need to download or install it from pycharm. How it is possible?我想在 cmd 上安装一个 package 然后它也可以在 pycharm 上工作。不需要从 pycharm 下载或安装它。这怎么可能? Please help me.请帮我。 I already installed that package on cmd.我已经在 cmd 上安装了 package。

Adding a Path添加路径

Go into File > Settings > Project Settings > Project Interpreter. Go 进入文件 > 设置 > 项目设置 > 项目解释器。

Then press configure interpreter, and navigate to the "Paths" tab.然后按配置解释器,并导航到“路径”选项卡。

pycharm path tab pycharm 路径选项卡

Press the + button in the Paths area.按路径区域中的 + 按钮。 You can put the path to the module you'd like it to recognize.您可以将路径放入您希望它识别的模块。

But I don't know the path.. Open the python interpreter where you can import the module.但我不知道路径.. 打开 python 解释器,您可以在其中导入模块。

foobarbaz/
  Package_name/
    __init__.py
    other_file.py

Most commonly you'll have a folder structure like this:最常见的是你会有这样的文件夹结构:

 foobarbaz/ Package_name/ __init__.py other_file.py

You want to add foobarbaz to the path here.您想将 foobarbaz 添加到此处的路径。

Assumption:假设:

  1. Initial installation of Python, Add Python to Path .初始安装Python,将Python加入Path was checked.被检查了。
  2. Initial installation of PyCharm.初始安装 PyCharm。
  3. A package is installed using command line pip install package .使用命令行pip install package

Result:结果:

  1. Package is installed in the default installation of Python. Package安装在Python的默认安装中。

Next:下一个:

  1. Start a new PyCharm project.启动一个新的 PyCharm 项目。
  2. Select File menu |Settings Select 文件菜单|设置
  3. Check the Base interpreter, it will likely be the python.exe file in the default Python installation.检查基本解释器,它可能是默认 Python 安装中的 python.exe 文件。 If not, locate the python.exe file and select it.如果没有,请找到 python.exe 文件和 select。
  4. Check Inherit global-site packages.选中继承全局站点包。
  5. Click Create Button单击创建按钮

Result: The project will be created with installed packages.结果:将使用已安装的包创建项目。

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

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