miketeo/pysmb

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

blinkbink opened this issue · 6 comments

python version : 3.5
ubuntu 18:04

hello, i get this error call import smb after install pysmb :
Traceback (most recent call last):
File "", line 1, in
File "/tmp/smb.py", line 2, in
from smb.SMBConnection import SMBConnection
ModuleNotFoundError: No module named 'smb.SMBConnection'; 'smb' is not a package

why this happen, i have try install using master data from github but still get error ?

I'm getting the same error - can't see anything on google that helps

You may not have installed pysmb correctly. In my projects, I create a virtualenv environment and install pysmb in it.

$> python3 -m venv myenv
$> source myenv/bin/activate
$myenv> pip install pysmb

In ubuntu, if you encounter "venv module not found error", you may need to install the python3-venv package.

I'm using py36-venv. While pysmb will install, it will not load. Please see below.

It would be nice to get this working. Otherwise, the file transfer code I write will have to be in python 2.7, and that means a lot of duplication of already written python3 functions.

Thanks!

$ scl enable rh-python36 bash
$ source ~/pydev/py36-venv/bin/activate

(py36-venv) $ python -V
Python 3.6.9

(py36-venv) $ python3 -m pip install pysmb
Collecting pysmb
Using cached pysmb-1.1.28.zip (1.3 MB)
Collecting pyasn1
Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Installing collected packages: pyasn1, pysmb
Running setup.py install for pysmb ... done
Successfully installed pyasn1-0.4.8 pysmb-1.1.28

(py36-venv) $ ./test-smb.py
Traceback (most recent call last):
File "./test-smb.py", line 9, in
from smb.SMBConnection import SMBConnection
ModuleNotFoundError: No module named 'smb'

I solved my problem - it was user error.

@iw4gtp : To be honest, I had never tried installing modules using pip as a module "python3 -m pip"

Please try:
(py36-venv) $ python3 test-smb.py

I suspect it could be an issue with your sha-bang in the first few lines of your test-smb.py script.
It could be using /usr/bin/python3. Usually, in virtualenv, I would use #!/usr/bin/env python3 for my scripts, so that it would use the python interpreter in virtualenv.