burritab
burritab

Reputation: 25

Is there a way to execute using specific architecture bit width (32/64 bit) version of python?

I have two scripts, one that uses 32-bit DLL files and one that uses too much memory to be usable with 32-bit version of python. When executing a python script from the command line or batch file, is there a way to specify which bit architecture to use, similar to how you can define which version to use?

Currently the solution being used is to have two different versions of python on the machine (ex: 32-bit Python 3.6 and 64-bit Python 3.7). Is it possible to have two different architectures of the same version and call them by architecture?

Upvotes: 0

Views: 296

Answers (2)

burritab
burritab

Reputation: 25

If you use the python launcher you can specify the bit width after the version of python. So when typed into the windows command prompt:

py -3.7-32 example.py

example.py would be run using 32-bit python 3.7

Upvotes: 0

João Amaro
João Amaro

Reputation: 195

I'm assuming you're using Windows, since you mention DLLs, but please update the answer with tags for completeness.

Yes, you most definitely can install the same version of Python, with two different bit-ness. Keep the following in mind though:

  • While installing one of them, change the default installation location;
  • Do not add both installation locations to the PATH environment variable;
  • See this to understand how to create a command-line alias in Windows, so you can for example create a python37_64 alias;

Upvotes: 1

Related Questions