How can I use virtualenv to use 32-bit and 64-bit Python in Windows?

后端 未结 3 519
抹茶落季
抹茶落季 2021-02-10 22:55

I have 64-bit Python (2.7.5) installed at C:\\Python27 and 32-bit Python at C:\\Python27_32.

I would like to use virtualenv to set up a 32-bit

相关标签:
3条回答
  • 2021-02-10 23:09

    For your virtual env to run after you have changed your paths you will need to install virtualenv into the 32 bit python - there is nothing stopping you having a copy of virtualenv in each python.

    Assuming you have python 2.7.c 64-bit as your default python and you have also installed python 2.7.x 32-bit you would need both anyway - also assuming that you are on windows your two pythons will be installed somewhere like:

    C:\Python27 and C:\Python27_64

    With the latter on your path.

    Also assuming that you have pip installed in both, you will need it for virtualenv anyway - to install virtualenv to the 32 bit python you can either run:

    Path\To\32Bit\pip install virtualenv
    

    or

    set path=C:\Python27;C:\Python27\Scripts;%path%
    rem The above should set your 32 bit to be found before your 64 bit
    pip install virtualenv
    
    0 讨论(0)
  • 2021-02-10 23:11

    If you installed the 32Bit version first, and install the 64Bit version second (And you added python to path), Then you can use the updated python launcher (py) to create the 64Bit version of your virtualenv

    py -m venv my-env-name

    0 讨论(0)
  • 2021-02-10 23:32

    in command prompt Use: set CONDA_FORCE_32BIT=1 conda create -n virtualenv_name python=x.x anaconda

    The above can be found @ How to install win-32 package on a 64-bit system with conda install I personally tried it and it worked successfully (32-bit python x.x installed). Using Anaconda is not necessary but it will install all of the anaconda packages like pandas.

    Disclaimer: The comment below is a caution and not an attack on the answer submitted by anyone else.

    As my friend told me "changing the path manually is discouraged, mostly because you'd have to inform other applications that use Python (and that you do not necessarily know of) to point to a different folder, and changes are not certain to be consistent across your system. In a way, virtualenvs do the same but in a cleaner and (sort of) predictable fashion".

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