socket服务器的搭建-Mac
2016-07-26 17:17
429 查看
原文:http://m.blog.csdn.net/article/details?id=51126881
socket服务器可通过python来搭建
在终端输入命名:
[/code]
看到提示:Iphone Chat server started表示创建成功.
但是有的时候看到的提示是:
No module named twisted.internet.protocol:表示本机上没有安装twisted,需要自己安装.
chatserver.py下载地址.
ope.interface/twisted官网下载地址:
https://pypi.python.org/pypi/zope.interface
https://twistedmatrix.com/trac/wiki/Downloads
ope.interface/twisted 百度网盘下载地址:
链接: http://pan.baidu.com/s/1qYtcu6K 密码: rr13
步骤如下:
1.苹果电脑一般都安装了python,在终端,输“which python”或“which python3”,会显示python的安装目录。
2.先安装zope.interface,才能安装twisted.
安装方法:下载gz压缩包,解压后,会看到有个”setup.py” 文件,在终端下,输入“python setup.py install”或“python3 setup.py install”.便可以安装zope.interface。
如果出现
[/code]
这一段错误,因为python路径是在系统路径下,默认不能写.(报错的原因就是因为权限不够)
解决方案:使用命令
[/code]
3.检查下MAC有没有自带twisted。
检查方法:打开python命令行,输入“import twisted”,如果没有任何提示,说明你已经有twisted了,若提示没有”twisted”模块,则需要自己安装twisted。
安装方法:参考zope.interface的安装,(如果权限不够,同样在命令之前加上sudo),安装完成之后再用”import twisted”测试一下
出现下图表示通过
之后就可以用命令,开启服务了
[/code]
一个小demo的实例程序:
地址:github
socket服务器可通过python来搭建
在终端输入命名:
python chatserver.py
[/code]
看到提示:Iphone Chat server started表示创建成功.
但是有的时候看到的提示是:
No module named twisted.internet.protocol:表示本机上没有安装twisted,需要自己安装.
chatserver.py下载地址.
ope.interface/twisted官网下载地址:
https://pypi.python.org/pypi/zope.interface
https://twistedmatrix.com/trac/wiki/Downloads
ope.interface/twisted 百度网盘下载地址:
链接: http://pan.baidu.com/s/1qYtcu6K 密码: rr13
步骤如下:
1.苹果电脑一般都安装了python,在终端,输“which python”或“which python3”,会显示python的安装目录。
2.先安装zope.interface,才能安装twisted.
安装方法:下载gz压缩包,解压后,会看到有个”setup.py” 文件,在终端下,输入“python setup.py install”或“python3 setup.py install”.便可以安装zope.interface。
如果出现
error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/ test-easy-install-411.write-test' The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: /Library/Python/2.7/site-packages/ **Perhaps your account does not have write access to this directory?** If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: http://peak.telecommunity.com/EasyInstall.html Please make the appropriate changes for your system and try again.
[/code]
这一段错误,因为python路径是在系统路径下,默认不能写.(报错的原因就是因为权限不够)
解决方案:使用命令
sudo python setup.py install
[/code]
3.检查下MAC有没有自带twisted。
检查方法:打开python命令行,输入“import twisted”,如果没有任何提示,说明你已经有twisted了,若提示没有”twisted”模块,则需要自己安装twisted。
安装方法:参考zope.interface的安装,(如果权限不够,同样在命令之前加上sudo),安装完成之后再用”import twisted”测试一下
出现下图表示通过
之后就可以用命令,开启服务了
python chatserver.py
[/code]
一个小demo的实例程序:
地址:github
相关文章推荐
- Git常用命令总结
- [Err] 1093 - You can't specify target table 'table' for update in FROM clause处理
- ios 验证码生成
- 一些线程安全的对象
- linux下多定时器的实现(经典)
- MySql——得到ResultSet的记录个数的正确方法
- Android实战打飞机游戏之子弹生成与碰撞以及爆炸效果(5)
- RabbitMQ - 引入库产生的一次pthread_create错误
- Word怎么转PDF详细教程
- SQL Server数据库的三种恢复模式:简单恢复模式、完整恢复模式和大容量日志恢复模式(转载)
- Linux下搭建一个简单的TCP通信
- appium环境搭建(python+windows)
- 浅识J2EE十三个规范
- OpenCV两种易于理解的访问像素的方法
- 常用排序算法——堆排序
- Apache POI使用详解
- I - Matches Game(异或运算符的使用)
- 堆和栈的区别(内存和数据结构)【转】
- HDU-5723-Abandoned country(kruskal+DFS)
- 5. Longest Palindromic Substring