Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I've found this code on a site for create and seed a torrent from python script.

import sys
import time
import libtorrent as lt

#Create torrent
fs = lt.file_storage()
lt.add_files(fs, "./test.txt")
t = lt.create_torrent(fs)
t.add_tracker("udp://", 0)
t.set_creator('libtorrent %s' % lt.version)
lt.set_piece_hashes(t, ".")
torrent = t.generate()    
f = open("mytorrent.torrent", "wb")

#Seed torrent
ses = lt.session()
ses.listen_on(6881, 6891)
h = ses.add_torrent({'ti': lt.torrent_info('mytorrent.torrent'), 'save_path': '.', 'seed_mode': True}) 
print("Total size: ") + str(h.status().total_wanted)
print("Name: ") +   
while True:
    s = h.status()
    state_str = ['queued', 'checking', 'downloading metadata', \
      'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume']

    print('\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
      (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, s.num_peers, state_str[s.state]))


The problem is that it use "libtorrent" and i can't install that library. Is there another library similiar to libtorrent, or another way to install it?

What I have tried:

I've tried to search everywhere on and the libtorrent site, but i can't stand how to install that package.
Updated 16-Apr-21 22:10pm

1 solution

You are asking at the wrong place. You need to ask the person or people that wrote this code. Or you could simply install the required library.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900