Skip to main content

Pyfilesystem2 over SMB using pysmb

Project description

Source PyPI Travis Codecov Codacy Format License


pyfilesystem2 PyPI fs Source fs License fs
six PyPI six Source six License six
pysmb PyPI pysmb Source pysmb License pysmb


Install directly from PyPI, using pip

pip install fs.smbfs



Use fs.open_fs to open a filesystem with an SMB FS URL:

import fs
smb_fs = fs.open_fs('smb://username:password@SAMBAHOSTNAME:port/share')

The opener can use either an IPv4 address or a NetBIOS hostname, using the NetBIOS name service to find the other token. Otherwise, if NetBIOS is not available, a new SMB connection can be established by using the IPv4 address and giving the hostname with the hostname URL parameter.

The following parameters can be passed as URL parameters: timeout, name-port, direct-tcp, hostname.


import fs.smbfs
smb_fs = fs.smbfs.SMBFS(
    host, username='guest', passwd='', timeout=15,
    port=139, name_port=137, direct_tcp=False

with each argument explained below:

either the host name (not the FQDN) of the SMB server, its IP address, or both in a tuple. if either the IP address or the host name is not given, NETBIOS is queried to get the missing data.
the username to connect with, defaults to ‘guest’ for anonymous connection.
an optional password, defaults to ‘’ for anonymous connection.
the timeout, in seconds, for NetBIOS and TCP requests.
the port the SMB server is listening on.
the port the NetBIOS naming service is listening on
set to True if the server is accessible directly through TCP, leave to False for maximum compatibility

Once created, the SMBFS filesystem behaves like any other filesystem (see the Pyfilesystem2 documentation), except if it was open in the root directory of the server, in which case the root directory of the SMBFS instance will be read-only (since SMB clients cannot create new shares).


Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker of the project if you need to report or ask something. If you are filling in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproductible situation.

See also

  • fs, the core Pyfilesystem2 library
  • fs.archive, enhanced archive filesystems for Pyfilesystem2
  • fs.sshfs, Pyfilesystem2 over SSH using paramiko

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fs.smbfs, version 0.6.3
Filename, size File type Python version Upload date Hashes
Filename, size fs.smbfs-0.6.3-py2.py3-none-any.whl (13.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size fs.smbfs-0.6.3.tar.gz (13.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page