简体   繁体   English

如何在Windows 7中运行python程序?

[英]How to run python programs in Windows 7?

I downloaded this tool to migrate MySQL to PostgreSQL: https://github.com/philipsoutham/py-mysql2pgsql 我下载了此工具以将MySQL迁移到PostgreSQL: https : //github.com/philipsoutham/py-mysql2pgsql

Python interactive code works properly so the python path is set in the right way. Python交互代码正常工作,因此以正确的方式设置了python路径。

When I type "py-mysql2pgsql" being in the directory: C:\\Users\\me , the downloaded tool doesn't run but ask me to choose the program to open that file. 当我在目录C:\\Users\\me键入“ py-mysql2pgsql”时,下载的工具无法运行,但请我选择打开该文件的程序。 The same situation when I'm in C:\\Users\\me\\py-mysql2pgsql 当我在C:\\Users\\me\\py-mysql2pgsql

How can I run this tool properly? 如何正确运行此工具?

Windows does not understand shebang lines in scripts (#!/usr/bin/env python) like Linux and Unix variants do. Windows无法像Linux和Unix变体那样理解脚本(#!/ usr / bin / env python)中的shebang行。 So Windows does not understand that this is a python script, you need to execute python yourself. 因此Windows无法理解这是一个python脚本,您需要自己执行python。

If python executable is in your path, you should be able to run: 如果您的路径中有python可执行文件,则应该可以运行:

python py-mysql2pgsql

If it is not in your path, you should be able to run: 如果它不在您的路径中,则应该可以运行:

path_to_python\python py-mysql2pgsql  (on my machine C:\Python27\python)

Note that this applies to any python script on Windows, not just this tool. 请注意,这不仅适用于Windows工具,还适用于Windows上的任何python脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM