Ensure coexistence of 64 bit and 32 bit pythons with anaconda

  • 2021-06-28 13:26:52
  • OfStack

background

Meigo wants to call the python script in MFC. The original code contains a library file that only supports x86 (super core file). python was originally installed by x64. Forcing the program to run will cause the function in the python header file to be unresolved.Considering that anaconda can easily manage the python version, anaconda is used to install the 32-bit python.

Some commands from Anaconda

1. View the current working platform: conda info


(base) C:\Users\Catlin Cao>conda info
 
 active environment : base
 active env location : F:\Anaconda3
  shell level : 1
 user config file : C:\Users\Catlin Cao\.condarc
 populated config files : C:\Users\Catlin Cao\.condarc
  conda version : 4.5.11
 conda-build version : 3.15.1
  python version : 3.7.0.final.0
 base environment : F:\Anaconda3 (writable)
  channel URLs : https://repo.anaconda.com/pkgs/main/win-32
    https://repo.anaconda.com/pkgs/main/noarch
    https://repo.anaconda.com/pkgs/free/win-32
    https://repo.anaconda.com/pkgs/free/noarch
    https://repo.anaconda.com/pkgs/r/win-32
    https://repo.anaconda.com/pkgs/r/noarch
    https://repo.anaconda.com/pkgs/pro/win-32
    https://repo.anaconda.com/pkgs/pro/noarch
    https://repo.anaconda.com/pkgs/msys2/win-32
    https://repo.anaconda.com/pkgs/msys2/noarch
  package cache : F:\Anaconda3\pkgs32
    C:\Users\Catlin Cao\AppData\Local\conda\conda\pkgs32
 envs directories : F:\Anaconda3\envs
    C:\Users\Catlin Cao\AppData\Local\conda\conda\envs
    C:\Users\Catlin Cao\.conda\envs
  platform : win-32
  user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Windows/10 Windows/10.0.17134
  administrator : False
  netrc file : None
  offline mode : False

You can see that this is a 32-bit platform.

2. Switch between 64 and 32 bits: set CONDA_FORCE_32BIT=1 is switched to 32 bits;set CONDA_FORCE_32BIT=is switching to 64 bits.

It is important to note that this switching environment has no effect on the installed python, that is, the original 64-bit python is now 64-bit, so you need to switch to 32-bit before installing python, and the installation needs to proceed under prompt. The new python created in navigator defaults to 64-bit.

3. Install python: conda create - n env_name python=3.6, if you need to install some packages, just add the corresponding package name after name.conda create-n env_name numpy matplotlib python=3.6.

4. Switching environment: conda activate env_name, conda deactivate env_name.

5. Remove Environment: conda remove-n env_name--all

6. Installation package: activate env_name, conda install pandas.Install all packages for the anaconda distribution: conda install anaconda, but this will be done in all environments, so you need to specify the installation environment: conda install -n env_name pandas

All the above operations are in Anaconda Prompt. It is more intuitive to install python with Anaconda graphical interface (Navigator), but it is important to note that whether you set up 32-bit environment in Prompt or not, the python installed with Navigator is 64-bit. You can try 1. Welcome to leave a message if you have objections.


Related articles: