lida
lida

Reputation: 177

How to run installed whl format of a python project

I convert my python project to a whl format and transfer it to the server for run. In the server first i install my whl via:

pip install myProject.whl

Now how to call a specific script of it (main.py)? If I go to python bash, then i can call my specific script(main.py) via import :

(venv) lida@dn:/opt$ python
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>import myProject.main

But i don't want to use it. I want to call main.py out of the python bash like this:

(venv) lida@dn:/opt$python myProject.main

The above code is not correct. What is the correct answer?

Thanks all

Upvotes: 1

Views: 1251

Answers (1)

Thomas
Thomas

Reputation: 10125

Try to run it with python -m:

python -m myProject.main

-m <module-name>
Search sys.path for the named module and execute its contents as the __main__ module.

Source: https://docs.python.org/3/using/cmdline.html#cmdoption-m

Upvotes: 2

Related Questions