简体   繁体   中英

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. 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 .

First find your virtualenv directory with

pyenv prefix <venv-name>

The python executable of the virtualenv should be <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. After that you can start a new Django Project via File>New>Project>Pydev>PyDev Django Project. Choose your predefined interpreter.

The Django Project should now work inside the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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