Hello Nobuaki,

    I have renamed src to thrift, but it is not working when called from the 
script.



Importing from python interpreter works if current dir is thrift-0.9.3/lib/py, 
but it fails if current dir is something else. But the os.environ[‘PYTHONPATH’] 
includes lib/py in both cases.

py $ pwd

/.../Thrift/thrift-0.9.3/lib/py

py $ python

Python 2.7.1 (r271:86832, May 11 2011, 09:08:00)

...

>>> import thrift.transport

>>> from thrift.transport import TTransport

>>> t = TTransport

>>> t.__dict__

{'TTransportFactoryBase': <class 
thrift.transport.TTransport.TTransportFactoryBase at 0x2323d50>, 
'TTransportException': <class 
'thrift.transport.TTransport.TTransportException'>, ...]



Running from the script fails, from same current dir:

py $ pwd

/.../Thrift/thrift-0.9.3/lib/py

py $ ~/Thrift/gen-py/force_rpc/force_rpc-remote

Traceback (most recent call last):

  File "/home/snadathu/Thrift/gen-py/force_rpc/force_rpc-remote", line 13, in 
<module>

    from thrift.transport import TTransport

ImportError: No module named thrift.transport



1.       Does that help in isolating the issue?

2.       Why does setup.py return error?



Cheers,

Sundar





-----Original Message-----
From: Nobuaki Sukegawa [mailto:[email protected]]
Sent: Saturday, November 21, 2015 1:49 PM
To: [email protected]
Subject: Re: ImportError: No module named thrift.transport



Hi Sundar,



Not sure why the installation does not work for you.

A quick workaround is to rename "src"  to "thrift".

Everything except C extension (accelerated binary protocol) should still work.



On Sat, Nov 21, 2015 at 8:28 AM Sundar Nadathur 
<[email protected]<mailto:[email protected]>> wrote:



> Hi all,

>     I have found many instances of this error "ImportError: No module

> named thrift.transport" in Google. However, running setup.py does not

> fix the problem for me. Please LMK what I should do differently.

>

> Specifically, I have generated Python code from a thrift file, and am

> trying to run the client. Here's the error:

> $ ./force_rpc-remote

> Traceback (most recent call last):

>   File "./force_rpc-remote", line 13, in <module>

>     from thrift.transport import TTransport

> ImportError: No module named thrift.transport

>

> I have installed the Thrift library under

> mypath/Thrift/thrift-0.9.3/lib/py:

> py $ ls

> CMakeLists.txt*  coding_standards.md  compat/  Makefile.am*

> Makefile.in README.md  setup.cfg  setup.py  src/

>

> I ran setup.py as follows:

> py $ sudo python setup.py install

> [sudo] password for snadathu:

> /tools/share/python/2.7.1/linux64/lib/python2.7/distutils/dist.py:267:

> UserWarning: Unknown distribution option: 'use_2to3'

>   warnings.warn(msg)

> running install

>

> However, it seems to return an error status:

> py $ echo $?

> 139

>

> I tried modifying setup.py as below, with no difference:

> setup(name = 'thrift', . . .

>         # use_2to3 = True,

>         use_2to3 = False,

>         **extensions

>     )

>

> Subsequently, as expected, force_rpc-remote throws ImportError. Please

> note that I have set PYTHONPATH to include both

> mypath/Thrift/thrift-0.9.3/lib/py and

> mypath/Thrift/thrift-0.9.3/lib/py/src/.

>

> Details:

>    Thrift 0.9.3

>    Python 2.7.1

>

> Cheers,

> Sundar

>

>

> ________________________________

>

> Confidentiality Notice.

> This message may contain information that is confidential or otherwise

> protected from disclosure. If you are not the intended recipient, you

> are hereby notified that any use, disclosure, dissemination,

> distribution, or copying of this message, or any attachments, is

> strictly prohibited. If you have received this message in error,

> please advise the sender by reply e-mail, and delete the message and any 
> attachments. Thank you.

>

________________________________

Confidentiality Notice.
This message may contain information that is confidential or otherwise 
protected from disclosure. If you are not the intended recipient, you are 
hereby notified that any use, disclosure, dissemination, distribution, or 
copying of this message, or any attachments, is strictly prohibited. If you 
have received this message in error, please advise the sender by reply e-mail, 
and delete the message and any attachments. Thank you.

Reply via email to