[Twisted-Python] importing twisted modules from my source tree

Jp Calderone exarkun at intarweb.us
Fri Oct 24 01:05:32 EDT 2003

On Thu, Oct 23, 2003 at 10:59:10PM +0000, Ricardo Niederberger Cabral wrote:
> But i get the following error when running my app (which eventually
> imports imgClient, who by it's turn eventually imports reactor from
> twisted.internet):
> Traceback (most recent call last):
>   File "./isnLib/net/imgClient.py", line 68, in connect
>     reactor.connectTCP(self.addr, self.port, factory)
> AttributeError: 'module' object has no attribute 'connectTCP'

  How is your app launched?  (I checked out the CVS, but couldn't find the
main entry point, so I couldn't reproduce the above exception).

> I've noticed that if I run "python isnLib/net/imgClient.py" on a
> command line, reactor is imported correctly (and then becomes a bound
> method of twisted.internet.default.SelectReactor).

  Indeed, this worked for me as well.

  A possibly unrelated point:

  Your "failsafe" code in imgServer.py is definitely not helpful.  Let the
user configure their own environment (I, for example, do not have
/usr/local/lib/python2.1).  Aside from adding random, possibly non-existent
paths to sys.path, adding site-packages from *different versions* of Python
will only cause you misery (to answer a question from the comments in the
code, the preferred way to include packages in a user's home directory is to
use sitecustomize.py to add those directories, or to set up PYTHONPATH

  If the import fails, I'd recommend just letting it fail, and including a
section in your README for people not familiar with Python on how to remedy
this problem.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20031024/b838ad89/attachment.pgp 

More information about the Twisted-Python mailing list