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 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)
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. 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.
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