简体   繁体   中英

How to associate django project with virtualenv

I'm working with pycharm 3 pro on windows. I'm trying to set up a virtualenv to develop django in.

I have my virualenv in /f/development3/tools/virtualenvs/. Its called "renv". I have a project in /f/PycharmProjects/ called "r1".

In pycharm I have set the interpreter to r1 to be the virtualenv "renv". However when I open a terminal and do:

/f/PycharmProjects/r1 $ which pip
/f/Python27/Scripts/pip

So it seems that the project is not assosciated with the virtualenv through pycharm. Rather than try to figure out how to do this in pycharm ( I've posted a question in their forum ) I would like to put my django project "into" the virtualenv using the command line ( or cutting/pasting ). How do I do this?

Well you would need to associate your project with the virtualenv assuming that have created a virtualenv in the first place. Then you would need to use virtualenvwrapper and then use the workon command. This is actually more involved than you'd initially expect.

I could give you a long explanation regarding this, but there is already an excellent tutorial regarding this. virtualenv and virtualenvwrapper

Please note that virtualenvwrapper is *nix specific, so for windows you would need to find an alternate solution. Luckily such a solution exists, and its for powershell .

Actually, there is a port of virtualenvwrapper for Windows, called virtualenvwrapper-win . It works specifically on the Windows command line (not powershell). You may, of course, prefer to work in powershell, but be aware of what your options are. The only drawback is that you need to do your git adds/commits, etc. in a separate git bash shell.

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