-
ywangd
This was caused by a bug in
pip
when it registers installed package, which is backed byRawConfigParser
. The RawConfigParser has its own string interpolation rule which relies on the percentage sign.The bug has now been fixed and you can get it by
selfupdate -f
. -
ywangd
It cannot be done.
greenlet
does not work in Pythonista.greenlet
is a pure C extension. It does not have any Python modules to be installed. That is what caused the error. C extension installation generally requires compiling C code which is impossible in Pythonista. -
ywangd
I tried to download setuptools and copy its
pkg_resources
sub-folder intosite-packages
. Thenimport pygal
just worked. Maybe we can make this a standard process to installpkg_resources
the first time stashpip
is called.By the way, these are the commands I used to install
pkg_resources
.pip download setuptools tar -zxvf setuptools-25.1.0.tar.gz cp setuptools-25.1.0/pkg_resources site-packages/
If there are any import errors afterwards, try restart Pythonista.
-
ywangd
This is the use case that StaSh was initially created for. You can invoke your script from within StaSh similar to what you would do on a PC. You can redirect the output to a file as the follows:
your_script.py > output.txt
More details here https://github.com/ywangd/stash
If you have previous experience with Linux shell, things should be quite familiar. -
ywangd
OmniClass
is a stub class defined in StaSh pip. So maybe somehow it was getting in the way. Try restart Pythonista, i.e. swipe up to remove from task list. -
ywangd
Thanks a lot @dgelessus ! One cannot ask for a better answer!
-
ywangd
@omz @dgelessus
The following simple code usingpythonapi
works well in Python 2 but errors out in Python 3.import ctypes p3 = ctypes.pythonapi state = p3.PyGILState_Ensure() p3.PyRun_SimpleString('print(42)') p3.PyGILState_Release(state)
The error is
name 'p' is not defined
which is very weird as it suggests that the API does not even parse the given string correctly. It somehow tries to get a variable namedp
which is in fact the first character ofprint
. -
ywangd
Thanks @dgelessus
The use ofPyDLL
worked for some initial tests! -
ywangd
@omz
ctypes.pythonapi
always points to the C API of Python 3 regardless of the default interpreter setting. Is there anyway to access the Python 2 version ofpythonapi
object? It would be even more fantastic if both of them can be accessed without switch interpreter setting.I also tried to manually load the library with
ctypes.CDLL(os.path.join(os.path.dirname(sys.executable), 'Frameworks/PythonistaKit.framework/PythonistaKit'))
Although it seems to load the Python 2 API and
Py_GetVersion
does show the version to be 2.7. But it is somehow not really usable. Many API calls working with the Python 3 API would not work or even simply crash the app.Any help is appreciated.
-
ywangd
@korakot @plessner There was a bug in stash pip command that prevented it from parsing package names with uppercase letters. The bug is now fixed and you can get the updated version via
selfupdate
.