Virtualenv keeps loading global site packages on Windows

前端 未结 3 479
[愿得一人]
[愿得一人] 2021-02-06 07:49

I\'ve looked around on SO, and the answers I have found to my problem haven\'t allowed me to solve it yet.

I want to use isolated virtualenv environments, but for one re

相关标签:
3条回答
  • 2021-02-06 08:05

    A little bit of extra .bat hackery can easily fix this. My standard additions to activate.bat are:

    REM custom venv settings
    set PYTHONPATH=%\VIRTUAL_ENV%;%\VIRTUAL_ENV%\conf;%\VIRTUAL_ENV%\apps
    set DJANGO_SETTINGS_MODULE=settings
    
    ftype Python.File=%VIRTUAL_ENV%\Scripts\python.exe %1 %*
    

    and to deactivate.bat

    REM restore ftype
    ftype Python.File=C:\tools\Python27\python.exe %1 %*
    
    0 讨论(0)
  • 2021-02-06 08:09

    I had the same "Access denied" problems as Dan with m0nonoke's answer on my Windows 7 setup using cmd.exe.

    But I found this work around using a replacement shell TCC/LE and a customised startup file...

    Under working directory create subdirectory config. In this directory create startup file for TCC/LE called tcstart.btm

    @echo off
    rem Override system python binding to handle virtualenvironments
    set .py;.pyc=python.exe
    

    Now create (copy) TCC/LE shortcut on desktop and rename it appropriately. Open Properties for shortcut and add to Target “C:\django\config\tcstart.btm”. You probably want to set Start in to something useful, like C:\django

    Solution found in this guide on installing Django and Windows.

    0 讨论(0)
  • 2021-02-06 08:26

    You could make a .bat file and modify PATH and PYTHONPATH in there, and then run .py from that .bat file. Something like this i think

    set PATH=C:\Python26; python myfile.py

    Ofcourse, add anything else to your path that you want.

    0 讨论(0)
提交回复
热议问题