使用 PyCharm 从 GitHub 安装 Python 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21048073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install Python package from GitHub using PyCharm
提问by Jim
I created a VirtualEnv in PyCharm to install my Python packages. I wanted to install this fork of the django project from GitHub.
我在 PyCharm 中创建了一个 VirtualEnv 来安装我的 Python 包。我想从 GitHub 安装这个 django 项目的分支。
https://github.com/django-nonrel/django
https://github.com/django-nonrel/django
For packages available from PyPII would normally use the built-in search tool in PyCharm, but I'm not sure how to correctly install it into the VirtualEnv within PyCharm from GitHub. Would anyone know how to do this?
对于PyPI提供的包,我通常会使用 PyCharm 中的内置搜索工具,但我不确定如何从 GitHub 将其正确安装到 PyCharm 中的 VirtualEnv。有谁知道如何做到这一点?
采纳答案by Alvaro
I personally would suggest cloning the repository to a local folder
我个人建议将存储库克隆到本地文件夹
git clone https://github.com/django-nonrel/django.git my_folder
Then install it manually:
然后手动安装:
cd my_folder
python setup.py build
python setup.py install
I wouldn't recommend using PyCharm to install the packages, since you will become dependent on it... Use pip instead, wich is the tool pycharm uses anyway
我不建议使用 PyCharm 来安装软件包,因为你会变得依赖它......改用 pip,这就是 pycharm 使用的工具
回答by Mike
I was struggling to find a way to do this within the PyCharm UI, but it is possible through the integrated Python console:
我一直在努力在 PyCharm UI 中找到一种方法来执行此操作,但可以通过集成的 Python 控制台实现:
- Load your project with the appropriate VE
- Under the Tools dropdown, click Python Console
Then use pip from within the console:
import pip pip.main(['install','packagename'])
- 使用适当的 VE 加载您的项目
- 在工具下拉菜单下,单击 Python 控制台
然后在控制台中使用 pip:
import pip pip.main(['install','packagename'])
回答by marcjae
Alternatively, in console:
或者,在控制台中:
pip install -e git+https://github.com/%%#egg=Package
回答by Gord Thompson
The following worked for me with PyCharm Community Edition 2018.1 on Xubuntu 16.04:
以下内容适用于 Xubuntu 16.04 上的 PyCharm 社区版 2018.1:
After loading the project (which was associated with the virtual environment that I wanted to update), I opened PyCharm's Terminal window (AltF12, or View > Tool Windows > Terminal) and then used the command
加载项目(与我想要更新的虚拟环境相关联)后,我打开 PyCharm 的终端窗口(AltF12,或查看 > 工具窗口 > 终端),然后使用命令
pip install git+https://github.com/v-chojas/pyodbc@unicodecolumnsize
to install pyodbc from the "unicodecolumnsize" branch of the fork maintained by user v-chojas.
从用户维护的 fork 的“unicodecolumnsize”分支安装 pyodbc v-chojas。
Once the install was completed the package showed up in the Project Interpreter widow
安装完成后,该包将显示在 Project Interpreter 寡妇中
On OSX+PyCharm 2018.1 needed to restart PyCharm to pick up the change and recognize the imports from the newly installed packages.
在 OSX+PyCharm 2018.1 上需要重新启动 PyCharm 以获取更改并识别来自新安装包的导入。
回答by Rodrigo
I was with the same problem, all i did was : Configure the project interpreter to the Python3 inside the venv/scripts you are using the pip install. Remember to activate the venv. That's it , now you can use the pip install on pycharm or on prompot. The problem is that even with the "venv/lib/sitepackeges" in the your project's sys.path the pycharm looks only for the packages where the project interpreter is
我遇到了同样的问题,我所做的只是:在您使用 pip install 的 venv/scripts 中将项目解释器配置为 Python3。记得激活venv。就是这样,现在您可以在 pycharm 或 prompot 上使用 pip install。问题是,即使在项目的 sys.path 中有“venv/lib/sitepackeges”,pycharm 也只查找项目解释器所在的包


