Running python script without libraries installed
I apologize in advance, this is probably a stupid question, but I am confused and need a straightforward answer.
I have a Python script running with functions scipy
and numpy
, and I need to run it on a machine with Python installed, but without modules scipy
and numpy
. How should I do it? Is this the .pyc
answer or should I do something more complex?
Notes:
- I don't want to use
py2exe
. I know about this, but it doesn't fit this problem. - I read these questions ( What is the difference between .py and .pyc files ? , Python pyc files (main file not compiled?) ) With an obvious link to this problem, but since I am a physicist and not a programmer, I am completely lost.
source to share
Python first "compiles" the program to bytecode, and then outputs that bytecode through the interpreter.
So, if your code is all Python code, you can generate bytecode once and then use it at runtime in Python. In fact, I've seen projects like this where a developer has just reviewed a bytecode specification and implemented a bytecode parsing engine. It is very lightweight so it is useful for eg "Python on a Chip" etc.
The problem is with external libraries not fully written in Python (e.g. numpy, scipy).
Python provides a C-API that allows you to create (using C / C ++ code) objects that appear as Python objects in it. This is useful for speeding up work, interacting with hardware, using C / C ++ libs.
source to share
It's impossible.
A pyc
-file is nothing more than a python file compiled to byte code. It does not contain any modules that this file imports!
Also, the module numpy
is an extension written in C (and some Python). An essential part of this is the shared libraries that are loaded into Python at runtime. You need those for numpy to work!
source to share