'twistd' is not a recognized internal or external command

微笑、不失礼 提交于 2020-01-02 10:04:11

问题


I'm trying to develop a Twisted Web server but can't seem to run the twistd command. I've tried setting the python path and even included the path to the twistd.py script in my Path but nothing seems to work.

I'm using Twisted 12.0.0 and Python 2.7 on Windows. Any help would be hugely appreciated.


回答1:


You need to set the %PATHEXT% environment variable to include .py, as well as %PATH% including the path to twistd. Your most-recently-installed version of Python should then automatically launch it, assuming the filetype association was set correctly by the installer.




回答2:


Create a twistd.bat and save it under your Scripts directory; if you're using virtualenv, the exact path is: <virtualenv_root_dir>\Scripts\twistd.bat

Edit twistd.bat and put the ff:

@echo off
python %~dp0twistd.py %*

Assumptions:

  • There should be a <virtualenv_root_dir>\Scripts\twistd.py after installing Twisted in your virtualenv.
  • <virtualenv_root_dir>\Scripts is in your %PATH%

Then after activating your virtualenv, you should be able to run twistd directly, e.g.

twistd web --path . --port 8080

I myself uses this approach in a Windows XP machine.



来源:https://stackoverflow.com/questions/9440303/twistd-is-not-a-recognized-internal-or-external-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!