26

I'm trying something simple. I clone a repository and then I want to create a virtualenv in it:

hg clone ssh://hg@bitbucket.org/neves/repo site
virtualenv site

When I run the command to create a Python virtualenv in an exiting project, a directory named local is created. All the contents of the "site" dir are copied to this local dir. I don't want this behaviour. Am I doing something wrong? How do I create a virtualenv without creating this local dir?

I'm using virtualenv 1.10.1

Cœur
  • 37,241
  • 25
  • 195
  • 267
neves
  • 33,186
  • 27
  • 159
  • 192

2 Answers2

55

Not sure if it is still helpful, but you can do this.

virtualenv .

Install was fine with me.

Andy K
  • 4,944
  • 10
  • 53
  • 82
  • 3
    That's just what I wanted. To create a virtualenv using current directory's name :) Thanks! – Nikita Hismatov Dec 04 '16 at 16:55
  • Welcome @NikitaHismatov – Andy K Dec 04 '16 at 17:04
  • 1
    I want also confirm that those command worked for me in W7 from a proxy server(as instead for pip one need to include the --proxy yourproxyadressparameters) – Carmine Tambascia Dec 01 '17 at 10:34
  • hi @CarmineTambascia an upvote on my answer is always appreciated ;) – Andy K Dec 01 '17 at 10:50
  • @Andy actually I have faced the state that on creating that virtual env with that command, it used the based Python interpreter, but unfortunately it does not see packages I have installed in the virtual env itself(I noticed it as Pycharm is giving me "not found reference for things like django.db, but django it's been installed in the Virtualenv. I was looking at the answer here https://stackoverflow.com/questions/42145656/unresolved-reference-django-in-pycharm but isn't been installed any Interpreter into the virtual Env. – Carmine Tambascia Dec 01 '17 at 12:49
  • Any suggestions?Does maybe on creating the env it's better specify the Python Interpreter explicitly? – Carmine Tambascia Dec 01 '17 at 12:49
  • 1
    Actually I am just noticing that inside the Scripts folder in the env there is a valid python.exe . Then issue sorted – Carmine Tambascia Dec 01 '17 at 13:30
  • 3
    This also worked with the new version `venv` : `python3 -m venv .` – Jamil Said May 14 '20 at 04:54
4

This just happens on some platforms (like Ubuntu) and is necessary because a virtualenv imitates the machine's installation, and local is part of that. Just add it to your SCM's ignore facility (e.g. .gitignore).

jhermann
  • 2,071
  • 13
  • 17
  • Excuse me, but I didn't understand why it is necessary to have a copy of everything there. I just delete it. It is just an annoyance, but maybe it is a hint that I'm not doing something right. – neves Oct 04 '13 at 17:21
  • 1
    Looks like `pyvenv` creates less directories then vertualenv: ```bin/ include/ lib/ pyvenv.cfg``` – chhantyal Nov 10 '15 at 12:05
  • 1
    You're free to delete it. As jhermann mentioned, it tries to imitate the Ubuntu approach of keeping Python-related libraries and modules in `~/.local`, for example if you installed them using `pip` and the `--user` argument. – hyperTrashPanda Feb 04 '19 at 11:05