0

What I want to do.

I want to access share folder of remote Windows10 computer using smb module but I could not do it.

Environment

  • Windows10
  • Python v3.10.2
  • pysmb v1.2.7

What I confirmed and my question.

Firstly I installed pysmb module as following:

python -m pip install pysmb

In the command line:

Collecting pysmb
  using cached pysmb-1.2.7.zip(1.3MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pyasn1 in c:\----\lib\site-packages( from pysmb) (0.4.8)
Using legacy 'setup.py install' for pysmb, since package 'wheel' is not installed.
Installing collected packages: pysmb
  Running setup.py install for pysmb ... done
Successfully installed pysmb-1.2.7

So I thought pysmb module was installed on my environment. So I made a python code as follows:

import platform
from smb.SMBConnection import SMBConnection

conn = SMBConnection(userID  = "myname",
                    password = "hoge",
                    my_name  = platform.uname().node,
                    remote_name = "192.168.0.3",
                    domain   = "",
                    use_ntlm_v2 = True)

conn.connect("192.168.0.3",139)

items = conn.listPath("data","/")
for item in items:
    print(item)

When I run the code, following error was emerged.

*File test.py, line 2, in <module>
from smb.SMBConnection import SMBConnection

builtin.ModuleNotFoundError: No module named 'smb.SMBConnection'; 'smb' is not a package.

I don't understand why the error come up. I also tried:

from smb.SMBConnection import *

But the result was same. Which part is invalid to run this code ? Please let me know what I should correct to make it work. Thank you.

Folder Structure

kazutaka
  • 39
  • 1
  • 6
  • Do you get any errors if you try `import smb` ? – alec_djinn Feb 14 '22 at 09:43
  • Dear alec_djinn, I tried "import smb" but the same result. it says "smb is not a package". – kazutaka Feb 14 '22 at 09:45
  • 1
    What is the file name of your script? Make sure you are not having spurious `smb.py` files in your working directory, else Python will try importing them instead of the `smb package` – alec_djinn Feb 14 '22 at 09:47
  • Check this https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at – alec_djinn Feb 14 '22 at 09:49
  • Dear alec_djinn, Thank you for your advise. the filename of my python code is "smb.py". It was first time to encounter this issue. I learned. When I changed the filename, it works ! – kazutaka Feb 14 '22 at 10:39

0 Answers0