Change Python 64bit environment to 32bit environment with Anaconda

Introduction

This is Qiita's first post. Thank you. I created a 32-bit environment for Python with Anaconda, loaded a DLL compiled with 32bit, and worked on it. (See here for how to create a Python 32-bit environment. Create a 32-bit Python environment with Anaconda) Then, at one point, ʻOSError: [WinError 193]% 1 is not a valid Win32 application. I now get the error `</ b>. Apparently the Python environment has changed from 32bit to 64bit, To solve this, change Python's 64-bit environment to a 32-bit environment.

Check the Python environment

Check if Python in the current environment is 64bit or 32bit. Start Python and it is 32bit for "MSC v.1916 32 bit" and 64bit for "MSC v.1916 64 bit".

$ python
Python 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

In the above case, it is 64bit. Another option is to look at sys.maxsize. Start Python, import sys, and display sys.maxsize. For 32-bit it is 2 ^ 31-1 = 2147483647, and for 64-bit it is 2 ^ 63-1 = 9223372036854775807.

maxsize.py


import sys
print(sys.maxsize)

Check / change conda settings

Use the conda info command to display the conda information and check the platform.

$ conda info

   ...abridgement
               platform : win-64
   ...abridgement

Set CONDA_SUBDIR to win-32 with set CONDA_SUBDIR = win-32 and check the platform again.

$ set CONDA_SUBDIR=win-32 
$ conda info

   ...abridgement
               platform : win-32
   ...abridgement

Reinstall python

Reinstall Python. All you have to do is conda update --all.

$ conda update --all

    ...abridgement
python             pkgs/main/win-64::python-3.6.9-h5500b~ --> pkgs/main/win-32::python-3.6.8-h9f7ef89_7
    ...abridgement

You can see that it has changed from win-64 to win-32.

Check for changes in the Python environment

Start Python and check.

python
Python 3.6.8 |Anaconda, Inc.| (default, Feb 21 2019, 18:28:22) [MSC v.1916 32 bit (Intel)] on win32

OK if it is "MSC v.1916 32 bit"

Recommended Posts

Change Python 64bit environment to 32bit environment with Anaconda
Install Python environment with Anaconda
From Python environment construction to virtual environment construction with anaconda
[Python] Building an environment with Anaconda [Mac]
[Python] Create a virtual environment with Anaconda
Build Python environment with Anaconda on Mac
How to add python module to anaconda environment
Use Python 3.8 with Anaconda
Python environment with docker-compose
Virtual environment with Python 3.6
Building an Anaconda environment for Python with pyenv
Building a Python environment with WLS2 + Anaconda + PyCharm
Use Python in Anaconda environment with VS Code
A memo that allows you to change Pineapple's Python environment with pyenv
Python + Anaconda + Pycharm environment construction
Connect to BigQuery with Python
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
Manage python environment with virtualenv
Connect to Wikipedia with Python
Change IP settings to ACL of conoha with python
Post to slack with Python 3
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Build python3 environment with ubuntu 16.04
Anaconda3 python environment construction procedure
[Python] Change dtype with pandas
Prepare python3 environment with Docker
Build python environment with direnv
Full bit search with Python
Python development environment with Windows + Anaconda3 + Visual Studio Code
Switch python to 2.7 with alternatives
Write to csv with Python
How to change Python version
[LDAP environment construction: 7] Add / search / change / delete users with Python
Double-click ipynb in windows + anaconda environment to open with jupyter-notebook
How to run an app built with Python + py2app built with Anaconda
How to build a python2.7 series development environment with Vagrant
Web application with Python3.3.1 + Bottle (1) --Change template engine to jinja2
How to get into the python development environment with Vagrant
How to install python using anaconda
Python: How to use async with
Get started with Python! ~ ① Environment construction ~
Link to get started with python
Anaconda python environment construction on Windows 10
Build python virtual environment with virtualenv
Setup modern Python environment with Homebrew
[Python] Write to csv file with Python
Create folders from '01' to '12' with python
Nice to meet you with python
Install python2.7 on windows 32bit environment
Try to operate Facebook with Python
Learn search with Python # 2bit search, permutation search
Install scrapy in python anaconda environment
Output to csv file with Python
Build Mysql + Python environment with docker
Change python default encoding to utf-8
Create a virtual environment with Python!
Convert list to DataFrame with python
MP3 to WAV conversion with Python
Python environment construction (pyenv, anaconda, tensorflow)
To do tail recursion with Python2
Building a virtual environment with Python 3