简体   繁体   English

如何使用pyenv创建的virtualenv设置Django PyDev项目

[英]How to setup Django PyDev project with virtualenv created with pyenv

I have set up a python virtual environment with pyenv on Linux Now I would like to create a Django project in PyDev with one of these virtual environments. 我已经在Linux上使用pyenv设置了python虚拟环境现在,我想在PyDev中使用这些虚拟环境之一创建Django项目。 However, I cannot figure out how to locate my virtual environment, since running which python in the virtual environment only gives me the generic /home/rbu/.pyenv/shims/python . 但是,我无法弄清楚如何定位我的虚拟环境,因为在虚拟环境中运行which python只给了我通用的/home/rbu/.pyenv/shims/python

First find your virtualenv directory with 首先找到您的virtualenv目录

pyenv prefix <venv-name>

The python executable of the virtualenv should be <path>/<to>/<venv>/bin/python . virtualenv的python可执行文件应为<path>/<to>/<venv>/bin/python

Now set up a new interpreter in Eclipse Preferences>PyDev>Interpreters>Python Interpreter using the location of the executable and a adequate name. 现在,使用可执行文件的位置和适当的名称在Eclipse Preferences> PyDev> Interpreters> Python Interpreter中设置一个新的解释器。 After that you can start a new Django Project via File>New>Project>Pydev>PyDev Django Project. 之后,您可以通过File> New> Project> Pydev> PyDev Django Project启动一个新的Django Project。 Choose your predefined interpreter. 选择您的预定义解释器。

The Django Project should now work inside the virtualenv. Django项目现在应该在virtualenv内部工作。 For installing new packages it is probably easiest to just activate the virtualenv in the terminal with pyenv activate <venv-name> and pip install the package. 要安装新软件包,可能最简单的方法是在终端中使用pyenv activate <venv-name>点安装该软件包。

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

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