Re: How to run a module before install?

2019-01-14 Thread Peter Otten
jf...@ms4.hinet.net wrote:

>> h:\Temp\XL-Sudoku-Solver-master>py -m xl_sudoku_solver
> 
> Great! it works. Thank you, peter.
> 
> By the way, can you explain what these two command difference means? with
> or without a "-m". Or pointing where the document is. Thanks ahead:-)
> 

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

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to run a module before install?

2019-01-14 Thread jfong
Peter Otten於 2019年1月14日星期一 UTC+8下午4時04分33秒寫道:
> jf...@ms4.hinet.net wrote:
> 
> > I had download a module which has the following directory structure:
> > 
> > [XL-Sudoku-Solver_master]
> >   |__[tests]
> >   |__[xl_sudoku_solver]
> >   |__setup.py   |__ __init__.py
> >   |__problem1.txt   |__ __main__.py
> >   |__README.md  |__ ...
> >   |__ ...
> > 
> > The setup.py file has something like this:
> > -
> > ...
> > setup(
> > name="xl-sudoku-solver",
> > version="0.0.1.post3",
> > packages=['xl_sudoku_solver'],
> > entry_points={
> > "console_scripts": [
> > "xl-sudoku-solver = xl_sudoku_solver.__main__:main"
> > ]
> > },
> > ...
> > 
> > 
> > and the __main__.py has:
> > 
> > ...
> > from . import Solver, load_from_file, load_from_input, load_from_string
> > 
> > def main():
> > ...
> > 
> > if __name__ == '__main__':
> > main()
> > 
> > 
> > The README.md suggest the way of running it:
> > 
> > pip install xl-sudoku-solver
> > $ xl-sudoku-solver --time -f problem1.txt
> > 
> > But I like to run it before install. Is it possible? and how? I had try
> > two ways below but niether works:
> > 
> > 1) h:\Temp\XL-Sudoku-Solver-master>py xl_sudoku_solver --time -f
> > problem1.txt Traceback (most recent call last):
> >   File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
> > "__main__", mod_spec)
> >   File "C:\Python34\lib\runpy.py", line 85, in _run_code
> > exec(code, run_globals)
> >   File "xl_sudoku_solver\__main__.py", line 5, in 
> > from . import Solver, load_from_file, load_from_input,
> > load_from_string
> > SystemError: Parent module '' not loaded, cannot perform relative import
> > 
> > 2) h:\Temp\XL-Sudoku-Solver-master>py
> > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32
> > bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for
> > more information.
>  import xl_sudoku_solver
> 
> > 
> > Can't find the name "main", What to do?
> 
> With h:\Temp\XL-Sudoku-Solver-master as the current working directory try
> 
> h:\Temp\XL-Sudoku-Solver-master>py -m xl_sudoku_solver

Great! it works. Thank you, peter.

By the way, can you explain what these two command difference means? with or 
without a "-m". Or pointing where the document is. Thanks ahead:-)

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to run a module before install?

2019-01-14 Thread Peter Otten
jf...@ms4.hinet.net wrote:

> I had download a module which has the following directory structure:
> 
> [XL-Sudoku-Solver_master]
>   |__[tests]
>   |__[xl_sudoku_solver]
>   |__setup.py   |__ __init__.py
>   |__problem1.txt   |__ __main__.py
>   |__README.md  |__ ...
>   |__ ...
> 
> The setup.py file has something like this:
> -
> ...
> setup(
> name="xl-sudoku-solver",
> version="0.0.1.post3",
> packages=['xl_sudoku_solver'],
> entry_points={
> "console_scripts": [
> "xl-sudoku-solver = xl_sudoku_solver.__main__:main"
> ]
> },
> ...
> 
> 
> and the __main__.py has:
> 
> ...
> from . import Solver, load_from_file, load_from_input, load_from_string
> 
> def main():
> ...
> 
> if __name__ == '__main__':
> main()
> 
> 
> The README.md suggest the way of running it:
> 
> pip install xl-sudoku-solver
> $ xl-sudoku-solver --time -f problem1.txt
> 
> But I like to run it before install. Is it possible? and how? I had try
> two ways below but niether works:
> 
> 1) h:\Temp\XL-Sudoku-Solver-master>py xl_sudoku_solver --time -f
> problem1.txt Traceback (most recent call last):
>   File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
> "__main__", mod_spec)
>   File "C:\Python34\lib\runpy.py", line 85, in _run_code
> exec(code, run_globals)
>   File "xl_sudoku_solver\__main__.py", line 5, in 
> from . import Solver, load_from_file, load_from_input,
> load_from_string
> SystemError: Parent module '' not loaded, cannot perform relative import
> 
> 2) h:\Temp\XL-Sudoku-Solver-master>py
> Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32
> bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for
> more information.
 import xl_sudoku_solver

> 
> Can't find the name "main", What to do?

With h:\Temp\XL-Sudoku-Solver-master as the current working directory try

h:\Temp\XL-Sudoku-Solver-master>py -m xl_sudoku_solver


-- 
https://mail.python.org/mailman/listinfo/python-list


How to run a module before install?

2019-01-13 Thread jfong
I had download a module which has the following directory structure:

[XL-Sudoku-Solver_master]
  |__[tests]
  |__[xl_sudoku_solver]
  |__setup.py   |__ __init__.py
  |__problem1.txt   |__ __main__.py
  |__README.md  |__ ...
  |__ ...

The setup.py file has something like this:
-
...
setup(
name="xl-sudoku-solver",
version="0.0.1.post3",
packages=['xl_sudoku_solver'],
entry_points={
"console_scripts": [
"xl-sudoku-solver = xl_sudoku_solver.__main__:main"
]
},
...


and the __main__.py has:

...
from . import Solver, load_from_file, load_from_input, load_from_string

def main():
...

if __name__ == '__main__':
main()


The README.md suggest the way of running it:

pip install xl-sudoku-solver
$ xl-sudoku-solver --time -f problem1.txt 

But I like to run it before install. Is it possible? and how? I had try two 
ways below but niether works:

1) h:\Temp\XL-Sudoku-Solver-master>py xl_sudoku_solver --time -f problem1.txt
Traceback (most recent call last):
  File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
  File "C:\Python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "xl_sudoku_solver\__main__.py", line 5, in 
from . import Solver, load_from_file, load_from_input, load_from_string
SystemError: Parent module '' not loaded, cannot perform relative import

2) h:\Temp\XL-Sudoku-Solver-master>py
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xl_sudoku_solver
>>>

Can't find the name "main", What to do?


--Jach
-- 
https://mail.python.org/mailman/listinfo/python-list