如何安装python3.6,python3.6如何安装libtorrent?

如何安装python3.6,python3.6如何安装libtorrent?Doeslibtorrentsupportpython3now?ifsupportedhowtoinstallit.IwanttocodeaDHTCrawlerwithpython3,idon’tknowwhymycodealawaysgotConnectionresetbypeererror,soiwanttouse…

如何安装python3.6,python3.6如何安装libtorrent?

Does libtorrent support python3 now? if supported how to install it .

I want to code a DHT Crawler with python3 , i don’t know why my code alaways got Connection reset by peer error , so i want to use libtorrent , if there are another lib , i’m happy to use it . My biggest problem is , conversing the infohash to torrent file . Could it be a code problem?

class Crawler(Maga):

async def handler(self, infohash, addr):

fetchMetadata(infohash, addr)

def fetchMetadata(infohash, addr, timeout=5):

tcpServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

tcpServer.settimeout(timeout)

if tcpServer.connect_ex(addr) == 0:

try:

# handshake

send_handshake(tcpServer, infohash)

packet = tcpServer.recv(4096)

# handshake error

if not check_handshake(packet, infohash):

return

# ext handshake

send_ext_handshake(tcpServer)

packet = tcpServer.recv(4096)

# get ut_metadata and metadata_size

ut_metadata, metadata_size = get_ut_metadata(packet), get_metadata_size(packet)

# request each piece of metadata

metadata = []

for piece in range(int(math.ceil(metadata_size / (16.0 * 1024)))):

request_metadata(tcpServer, ut_metadata, piece)

packet = recvall(tcpServer, timeout) # the_socket.recv(1024*17) #

metadata.append(packet[packet.index(“ee”) + 2:])

metadata = “”.join(metadata)

logging.info(bencoder.bdecode(metadata))

except ConnectionResetError as e:

logging.error(e)

except Exception as e:

logging.error(e)

finally:

tcpServer.close()

解决方案

Yes, libtorrent (is supposed to) support python 3.

The basic way to build and install the python binding is by running the setup.py. That requires that all dependencies are properly installed where distutils expects them though. If this works it’s probably the simplest way so it’s worth a shot. I believe you’ll have to invoke this python script using python3, if that’s what you’re building for.

To build using the main build system (and install the resulting module manually) you can follow the steps in the .travis file (for unix) or the appeyor file for windows.

In your case you want to specify a 3.x version of python, but the essence of it is:

brew install boost-python

echo “using python : 2.7 ;” >> ~/user-config.jam

cd bindings/python

bjam -j3 stage_module libtorrent-link=static boost-link=static

To test:

python test.py

Note, in the actual build step you may want to link shared against boost if you already have that installed, and shared against libtorrent if you have that installed, or will install it too.

On windows:

add the following to $HOMEPATH\user-config.jam:

using msvc : 14.0 ;

using gcc : : : -std=c++11 ;

using python : 3.5 : c:\\Python35-x64 : c:\\Python35-x64\\include : c:\\Python35-x64\\libs ;

Then run:

b2.exe –hash openssl-version=pre1.1 link=shared libtorrent-link=shared stage_module stage_dependencies

To test:

c:\Python35-x64\python.exe test.py

今天的文章如何安装python3.6,python3.6如何安装libtorrent?分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/25258.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注