0

I struggle with virtual enviroment:
when I try to create env to my project like this

PS D:\Programowanie ;3\Python\DjangoProjects\VeryFirstDjangoProject> python -m virtualenv venv
created virtual environment CPython3.9.1.final.0-64 in 253ms
  creator CPython3Windows(dest=D:\Programowanie ;3\Python\DjangoProjects\VeryFirstDjangoProject\venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\vigor\AppData\Local\pypa\virtualenv)
    added seed packages: pip==21.1.1, setuptools==56.0.0, wheel==0.36.2
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
PS D:\Programowanie ;3\Python\DjangoProjects\VeryFirstDjangoProject> venv\Scripts\activate

it contains also global packages which I don't want.

(venv) PS D:\Programowanie ;3\Python\DjangoProjects\VeryFirstDjangoProject> pip list
    Package           Version
    ----------------- -------
    appdirs           1.4.4  
    asgiref           3.4.1  
    astroid           2.4.2  
    colorama          0.4.4
    cycler            0.10.0
    distlib           0.3.1
    Django            3.2.6
    filelock          3.0.12
    isort             5.7.0
    kiwisolver        1.3.2
    lazy-object-proxy 1.4.3
    mccabe            0.6.1
    numpy             1.21.2
    Pillow            8.3.1
    pip               21.2.4
    pylint            2.6.0
    pyparsing         2.4.7
    python-dateutil   2.8.2
    pytz              2021.1
    setuptools        49.2.1
    six               1.15.0
    sqlparse          0.4.1
    toml              0.10.2
    virtualenv        20.4.6
    wrapt             1.12.1

Confusing thing is that when I look at the folder venv\Lib\site-packages there is no global packages in it, but as you can see above they appear on the pip list that was typed in running environment. Next thing is that when I install a package in my running venv it is also installed globally and vice versa.

It looks as if despite creating and activating venv "global python" was still running.

What I expect is when creating new venv it should contain only default packages without any packages that were installed before globally.

Here is what I've read before posting my question, but unfortunately I couldn't find there a specific guide what to do to fix that problem. virtualenv --no-site-packages and pip still finding global packages?

Please be understanding, I'm newbie in that world and i feel a little bit lost and overwhelmed by that kind of problems...

viGor027
  • 67
  • 6
  • The question you linked has an answer to the problem. Did you research it? – gshpychka Aug 31 '21 at 11:13
  • Yes, but I still struggle e.g. I cannot use --no-site-packages, it's unrecognized argument in cmd. Is PYTHONPATH the same as enviromental variables on my computer, is it about that? – viGor027 Aug 31 '21 at 11:40
  • The semicolon in your path might be exposing a bug in path name handling inside virtualenv and/or something else you are using. – tripleee Aug 31 '21 at 12:19
  • @tripleee so my venv problems can be caused by that folder name ? – viGor027 Aug 31 '21 at 12:28
  • I am lucky enough to not have access to Windows so this is speculative, but it should be easy enough to investigate. Just create a new virtualenv in a place which doesn't have odd characters in the directory path and see if it helps. – tripleee Aug 31 '21 at 12:31
  • No matter if semicolon in the directory name caused this problem, having anything else than normal characters (for me that's letters of English alphabet, numbers hyphen, underscore, dot and perhaps @ if you must) in directory names will cause problems sooner than later. I also try to omit spaces when possible (and usually it IS possible). – Petr Blahos Aug 31 '21 at 12:42
  • @PetrBlahos I reinstalled the whole python, and changed the name of that folder, suprisingly it helped and now it works as expected :D – viGor027 Aug 31 '21 at 14:14

0 Answers0