Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Use python to torrent?
-
Did you add zope.interface to the sys.path?
-
Sorry if this is really basic but in my /var/mobile/Applications/../Documents directory are the Twisted-14.0.0 and zope.interface-4.1.1 directories. My sys.path (by default) includes the Documents directory and I (obviously incorrectly) thought that the Documents subdirectories would be searched. Can you tell me exactly what I need to append to sys.path to get Twisted to run?
-
ihf I'm new to python so I may not be setting up modules correctly but I can never get the setup.py to run. The Documents folder imports so the modules should import. Make sure that in the zope.interface-4.1.1 has the zope folder directly under it. The default is zope.interface-4.1.1/src/zope Either add the src directory to sys.path.append('path to src') or move the zope folder directly under zope.interface-4.1.1
Again I'm new at this and not sure Twisted is 100% working but I am able to run small examples without error.
It also passes almost all of the tests. It's hangs and doesn't finish near the end though.
-
Thanks. At this point, I'd settle for mostly working. I tried adding the path to src and now I get an error on the same line in setup.py (55) "ImportError:No module named _sysconfigdata. I also get AttributeError {'userbase'}
-
ihf I did not run setup.py I just started using the module. I was able to get simple online examples that use Twisted to run.
-
OK. Another elementary question...if I enter a simple Twisted echo test:
from twisted.internet import protocol, reactor
I get:
No module named internet
I presume this is because the sys.path is not correctly set but nothing I have tried works. Any assistance would be greatly appreciated
-
ihf here is how I import my modules, used as an action script. Put modules in a site-packages dir under Documents
<pre>
import os
import syshome = os.getenv('HOME')+'/Documents/site-packages/'
modules = [home + name for name in os.listdir(home) if not home+name in sys.path]
sys.path.extend(modules)
</pre>Here is my directory listing.
<pre>
Documents/site-packages/Twisted-1.3.0/CREDITS
Documents/site-packages/Twisted-1.3.0/ChangeLog
Documents/site-packages/Twisted-1.3.0/LICENSE
Documents/site-packages/Twisted-1.3.0/README
Documents/site-packages/Twisted-1.3.0/admin
Documents/site-packages/Twisted-1.3.0/debian
Documents/site-packages/Twisted-1.3.0/doc
Documents/site-packages/Twisted-1.3.0/sandbox
Documents/site-packages/Twisted-1.3.0/setup.cfg
Documents/site-packages/Twisted-1.3.0/setup.py
Documents/site-packages/Twisted-1.3.0/static
Documents/site-packages/Twisted-1.3.0/tmlabs
Documents/site-packages/Twisted-1.3.0/twisted
Documents/site-packages/Twisted-1.3.0/win32</pre>
-
I don't have the site-packages directory but I just used /Documents/. I ran your script with this change and my sys.path appears to now include all of the parent directories under /Documents/. If I try "from twisted.internet import protocol, reactor", I get ImportError: Twisted requires zope.interface 3.6.0 or later: no module name zope.interface.Do I have to move the zope and twisted modules out of subdirectories?
-
I added the zope src directory to sys.path. Now "from twisted import..." gives an ImportError: cannot import name symlink
I wonder why you did not experience these problems.
-
If I comment out the "from os import symlink", Twisted appears to run (at least the few test scripts I have tried). I presume that Apple did not permit symlink? I'm not sure where Twisted uses it or what will break without it.
-
It sounds like you guys are making some good progress... Would it be possible for one of you to create a GitHub repo with you code for getting Twisted working on Pythonista? Discussion in this Forum would be more productive if we could look at a common code base. I would be willing to add a few test cases to such a repo if it existed.
-
-
@briarfox The offending line was "from os import symlink". Does that work for you? If not, then it must mean that you are not running "from twisted.internet import protocol, reactor" which is part of an example on the twisted web site.
-
@ihf just ran the example without a simlink error. It worked. Ran the server, ran the client and received a response.
<pre>
Server said: hello, world!
connection lost
Connection lost - goodbye!
</pre> -
Interesting. So what happens if you just type
from os import symlink
If that works then there must be a difference between our Pythonista libraries. If that fails then I would expect twisted/python/lockfile.py to fail (you can also try running that). If that fails then I wonder how you are getting
from twisted.internet import protocol, reactor
to work?
From my reading of the code,it only executes the import of symlink if it thinks the running system is not windows, otherwise it defines symlink in the lockfile module.
I presume that if you type
platform.isWindows() it returns FALSE. -
@ihf Your right I can not import symlink but I have no issue importing twisted.python.lockfile.
-
I don't understand that since I get the ImportError when I import twisted.python.lockfile and you get it when you import symlink. Since that module does the import symlink why would it import correctly for you?
-
@ihf I do not see an import of symlink in twisted.python.lockfile.
-
line 24.
-
I think I see the reason for the discrepancy. I am running the latest version of Twisted v1.4.0. Based on your post above, you are running v1.3.0. Lockfile changed.