Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource module not found on windows #73

Open
JayantKundu opened this issue Aug 6, 2021 · 5 comments
Open

resource module not found on windows #73

JayantKundu opened this issue Aug 6, 2021 · 5 comments

Comments

@JayantKundu
Copy link

hello.
resource module is only for UNIX system and I want this code to work on windows .
Any suggestions ?

@dwalton76
Copy link
Owner

If you can get python working on windows you should be able to run it. There might be a few kinks to work out though.

@hp1210cl
Copy link

如何在windows环境下运行rubiks-cube-NxNxN-solver

1.注释掉rubiks-cube-solver.py、LookupTable.py中的import resource,resource库在windows中无效
2.修改LookupTable.py
添加import wget
修改call(["wget", url])为wget.download(url)
3.但是wget下载很慢,使用第三方工具下载就要获取下载地址
注释掉LookupTable.py中的代码
#call(["wget", url])
#wget.download(url)

        #if not os.path.exists(filename_gz_no_dir):
            #raise Exception(f"failed to download {filename_gz} via {url}")

        #shutil.move(filename_gz_no_dir, filename_gz)

		#call(["gunzip", filename_gz])
替换为
	    with open("urls.txt","a") as f:
			f.write(url + '\n')
运行rubiks-cube-solver.py,从输出中找到下载的链接,使用第三方工具批量快速下载到lookup-tables文件夹中,再解压

4.修改rubiks-cube-solver.py,添加以下,即可正常显示颜色
from colorama import init
init()
5.安装Cygwin gcc,
因为Windows问题,需要修改ida_search_via_graph.c文件,注释掉include <sys/resource.h>
在rubikscubennnsolver的父目录下编译Makefile文件中的gcc -O3 -o ida_search_via_graph rubikscubennnsolver/ida_search_core.c rubikscubennnsolver/rotate_xxx.c rubikscubennnsolver/ida_search_666.c rubikscubennnsolver/ida_search_777.c rubikscubennnsolver/ida_search_via_graph.c -lm
将编译好的ida_search_via_graph.exe文件拷贝到rubikscubennnsolver文件夹下。
6.修改LookupTableIDAViaGraph.py中的代码
cmd = ["./ida_search_via_graph"]为 cmd = ["ida_search_via_graph"]
7.注释掉__init__.py中的下列语句,可以减少中间日志输出信息
logging.basicConfig(level=level, format="%(asctime)s %(filename)25s:%(lineno)d %(levelname)8s: %(message)s")
8.注释掉rubiks-cube-solver.py中下列语句

logger.info("*********************************************************************************")
logger.info("See /tmp/rubiks-cube-NxNxN-solver/index.html for more detailed solve instructions")
logger.info("*********************************************************************************\n")

logger.info("rubiks-cube-solver.py end")
logger.info(f"Memory : {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss:,} bytes")
logger.info(f"Time   : {end_time - start_time}")
logger.info("")

9.直接在rubiks-cube-solver.py所在目录下,打开cmd或者powershell,输入pyhton rubiks-cube-solver.py --state LFBDUFLDBUBBFDFBLDLFRDFRRURFDFDLULUDLBLUUDRDUDUBBFFRBDFRRRRRRRLFBLLRDLDFBUBLFBLRLURUUBLBDUFUUFBD

@cubhe
Copy link

cubhe commented Dec 19, 2021

如何在windows环境下运行rubiks-cube-NxNxN-solver

1.注释掉rubiks-cube-solver.py、LookupTable.py中的import resource,resource库在windows中无效 2.修改LookupTable.py 添加import wget 修改call(["wget", url])为wget.download(url) 3.但是wget下载很慢,使用第三方工具下载就要获取下载地址 注释掉LookupTable.py中的代码 #call(["wget", url]) #wget.download(url)

        #if not os.path.exists(filename_gz_no_dir):
            #raise Exception(f"failed to download {filename_gz} via {url}")

        #shutil.move(filename_gz_no_dir, filename_gz)

		#call(["gunzip", filename_gz])
替换为
	    with open("urls.txt","a") as f:
			f.write(url + '\n')
运行rubiks-cube-solver.py,从输出中找到下载的链接,使用第三方工具批量快速下载到lookup-tables文件夹中,再解压

4.修改rubiks-cube-solver.py,添加以下,即可正常显示颜色 from colorama import init init() 5.安装Cygwin gcc, 因为Windows问题,需要修改ida_search_via_graph.c文件,注释掉include <sys/resource.h> 在rubikscubennnsolver的父目录下编译Makefile文件中的gcc -O3 -o ida_search_via_graph rubikscubennnsolver/ida_search_core.c rubikscubennnsolver/rotate_xxx.c rubikscubennnsolver/ida_search_666.c rubikscubennnsolver/ida_search_777.c rubikscubennnsolver/ida_search_via_graph.c -lm 将编译好的ida_search_via_graph.exe文件拷贝到rubikscubennnsolver文件夹下。 6.修改LookupTableIDAViaGraph.py中的代码 cmd = ["./ida_search_via_graph"]为 cmd = ["ida_search_via_graph"] 7.注释掉__init__.py中的下列语句,可以减少中间日志输出信息 logging.basicConfig(level=level, format="%(asctime)s %(filename)25s:%(lineno)d %(levelname)8s: %(message)s") 8.注释掉rubiks-cube-solver.py中下列语句

logger.info("*********************************************************************************")
logger.info("See /tmp/rubiks-cube-NxNxN-solver/index.html for more detailed solve instructions")
logger.info("*********************************************************************************\n")

logger.info("rubiks-cube-solver.py end")
logger.info(f"Memory : {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss:,} bytes")
logger.info(f"Time   : {end_time - start_time}")
logger.info("")

9.直接在rubiks-cube-solver.py所在目录下,打开cmd或者powershell,输入pyhton rubiks-cube-solver.py --state LFBDUFLDBUBBFDFBLDLFRDFRRURFDFDLULUDLBLUUDRDUDUBBFFRBDFRRRRRRRLFBLLRDLDFBUBLFBLRLURUUBLBDUFUUFBD

如何在windows环境下运行rubiks-cube-NxNxN-solver

1.注释掉rubiks-cube-solver.py、LookupTable.py中的import resource,resource库在windows中无效 2.修改LookupTable.py 添加import wget 修改call(["wget", url])为wget.download(url) 3.但是wget下载很慢,使用第三方工具下载就要获取下载地址 注释掉LookupTable.py中的代码 #call(["wget", url]) #wget.download(url)

        #if not os.path.exists(filename_gz_no_dir):
            #raise Exception(f"failed to download {filename_gz} via {url}")

        #shutil.move(filename_gz_no_dir, filename_gz)

		#call(["gunzip", filename_gz])
替换为
	    with open("urls.txt","a") as f:
			f.write(url + '\n')
运行rubiks-cube-solver.py,从输出中找到下载的链接,使用第三方工具批量快速下载到lookup-tables文件夹中,再解压

4.修改rubiks-cube-solver.py,添加以下,即可正常显示颜色 from colorama import init init() 5.安装Cygwin gcc, 因为Windows问题,需要修改ida_search_via_graph.c文件,注释掉include <sys/resource.h> 在rubikscubennnsolver的父目录下编译Makefile文件中的gcc -O3 -o ida_search_via_graph rubikscubennnsolver/ida_search_core.c rubikscubennnsolver/rotate_xxx.c rubikscubennnsolver/ida_search_666.c rubikscubennnsolver/ida_search_777.c rubikscubennnsolver/ida_search_via_graph.c -lm 将编译好的ida_search_via_graph.exe文件拷贝到rubikscubennnsolver文件夹下。 6.修改LookupTableIDAViaGraph.py中的代码 cmd = ["./ida_search_via_graph"]为 cmd = ["ida_search_via_graph"] 7.注释掉__init__.py中的下列语句,可以减少中间日志输出信息 logging.basicConfig(level=level, format="%(asctime)s %(filename)25s:%(lineno)d %(levelname)8s: %(message)s") 8.注释掉rubiks-cube-solver.py中下列语句

logger.info("*********************************************************************************")
logger.info("See /tmp/rubiks-cube-NxNxN-solver/index.html for more detailed solve instructions")
logger.info("*********************************************************************************\n")

logger.info("rubiks-cube-solver.py end")
logger.info(f"Memory : {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss:,} bytes")
logger.info(f"Time   : {end_time - start_time}")
logger.info("")

9.直接在rubiks-cube-solver.py所在目录下,打开cmd或者powershell,输入pyhton rubiks-cube-solver.py --state LFBDUFLDBUBBFDFBLDLFRDFRRURFDFDLULUDLBLUUDRDUDUBBFFRBDFRRRRRRRLFBLLRDLDFBUBLFBLRLURUUBLBDUFUUFBD

很详细了 但是他们也看不懂中文啊(It's very detailed, but I guess they can't read Chinese.)

@hp1210cl
Copy link

How to make dwalton76's rubiks-cube-NxNxN-solver run under Windows
1.Commet out “import resource” in rubiks-cube-solver.py、LookupTable.py, Library resource doesn't work under Windows.
2.Modify LookupTable.py:
import wget
change call(["wget", url]) to wget.download(url)
3.Using wget to download is very slow, then you can use the third party downloader to finish downloading the lookuptables.
First, comment out the following lines in LookupTable.py:
#call(["wget", url])
#wget.download(url)

        #if not os.path.exists(filename_gz_no_dir):
            #raise Exception(f"failed to download {filename_gz} via {url}")

        #shutil.move(filename_gz_no_dir, filename_gz)

		#call(["gunzip", filename_gz])

Second, add the following code:
with open("urls.txt","a") as f:
f.write(url + '\n')
Third, try run rubiks-cube-solver.py, then find the ruls.txt file from output directory, get all the links of lookuptables, use any third party downloader to download all lookuptables,and unzip them to the lookup-tables directory.
4.In order to display right color, add the following codes to rubiks-cube-solver.py:
from colorama import init
init()
5.Install Cygwin gcc to compile the IDA seacher(omit the detailed steps). Then,
Commet out "include <sys/resource.h>" in ida_search_via_graph.c.
Under the rubikscubennnsolver's parent directory run the following command in cmd or powerShell:
gcc -O3 -o ida_search_via_graph rubikscubennnsolver/ida_search_core.c rubikscubennnsolver/rotate_xxx.c rubikscubennnsolver/ida_search_666.c rubikscubennnsolver/ida_search_777.c rubikscubennnsolver/ida_search_via_graph.c -lm
Copy the compled ida_search_via_graph.exe file to rubikscubennnsolver directory.
6.Change the code "cmd = ["./ida_search_via_graph"]" to "cmd = ["ida_search_via_graph"]" in LookupTableIDAViaGraph.py.
7.Commet out the following in init.py, it will reduse the logger output info.
logging.basicConfig(level=level, format="%(asctime)s %(filename)25s:%(lineno)d %(levelname)8s: %(message)s")
8.Commet out the following in rubiks-cube-solver.py, it will reduse the logger output info further.
logger.info("")
logger.info("See /tmp/rubiks-cube-NxNxN-solver/index.html for more detailed solve instructions")
logger.info("
\n")

logger.info("rubiks-cube-solver.py end")
logger.info(f"Memory : {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss:,} bytes")
logger.info(f"Time   : {end_time - start_time}")
logger.info("")

9.Under the directory of rubiks-cube-solver.py, using cmd or powerShell, run command as Daniel Walton's example:
pyhton rubiks-cube-solver.py --state LFBDUFLDBUBBFDFBLDLFRDFRRURFDFDLULUDLBLUUDRDUDUBBFFRBDFRRRRRRRLFBLLRDLDFBUBLFBLRLURUUBLBDUFUUFBD
10.Also you can code using Process class of .Net to get the solution.

@dwalton76
Copy link
Owner

Nice work @hp1210cl !! Could you submit a pull request with the changes needed to make the solver run on windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants