Psychopy unexpected keyword argument 'languageStyle' - python

I saw that psychopy now has support for RTL language:
http://www.psychopy.org/api/visual/textstim.html
https://discourse.psychopy.org/t/reshaping-english-text-to-arabic/4235/16
I used this manual to install the latest version using conda:
http://psychopy.org/installation.html
My version is: 1.90.2 with Python 3.5
However, when init TextStim with languageStyle I get an error:
from psychopy import visual
text_stim = visual.TextStim(self.window, height = height, wrapWidth = wrapWidth, bold= True, text= sentence, pos = (0,0) , color='white', languageStyle='RTL')
Any idea how can I use it?

Yes, #deceze is correct, this feature in the latest beta, available for download from this page: https://github.com/psychopy/psychopy/releases rather than the latest stable release available from http://psychopy.org/installation.html
EDIT: actually I see that you're installing PsychoPy via pip under Anaconda. I guess the pip version is also lagging behind the current beta release. You might need to clone or download from the PsychoPy GitHUb repository if you want the latest developer release running under your own Python installation.
Note that this feature still doesn't handle multi-line text correctly in Python experiments (the text flows from right to left but also from bottom-to-top). This is due to a limitation in the underlying pyglet library we use for drawing text. However, the latest betas also allow for generating online Javascript experiments that can be run from a browser. These handle Arabic text correctly without any issues whatsoever (and with no need to specify the language style setting at all).

Related

Pillow not detecting the libraqm DLL file

I am having issues with Pillow's text rendering features. I wanted to enable kerning for the font so that it looked nicer, but have descended into an endless rabbit hole of insanity.
When trying to run this code line:
draw.text((1255, 224), desc, font=font.font_variant(size=94), fill=0xff0000ff, features=['kern'])
I receive the following error message:
size, offset = self.font.getsize(
KeyError: 'setting text direction, language or font features is not supported without libraqm'
I've searched online for a long while and have found a few answers that have not yielded any results...
Most notably How to install pre-built Pillow wheel with libraqm DLLs on Windows? and Installing Raqm (Libraqm) Windows 10.
I was so stressed that I eventually copied and pasted the DLL files in every folder I could think of (such as System32, SysWOW64, Python38, Python38\Scripts, Python38\DLLs, etc.), but still failed.
I was even changing PATH, PYTHONPATH, and sys.path.
>>> from PIL import features
>>> features.check('raqm')
False
The check above always printed False
I inspected the code that checks if a feature is present and checked myself, it cannot find any DLL:
>>> imported_module = __import__('PIL._imagingft', fromlist=['PIL'])
>>> vars(imported_module)
{ ..., 'HAVE_RAQM': False, 'HAVE_FRIBIDI': False, 'HAVE_HARFBUZZ': False, ... }
For reference, these are my versions:
Windows 10 Pro 20H2
Pillow 8.2.0
Python 3.8.7
I have become very desperate for any answer... Looked online for a while and was not able to find much information, always only one or two Google results had some relevance to this issue.
I have the same problem
I tried placing libraqm.dll everywhere possible
After googling for days with no hope,
At the end I installed virtualbox and continued my project on Manjaro linux.
I have windows 10 Home
Version 10.0.19042 Build 19042
Pillow 8.2.0
Python 3.9.5

Programmatically check if wheel is compatible with Python installation

Is it possible to programmatically check if a wheel (whl) is compatible with the chosen Python installation before attempting to install?
I'm making an automated packages installer (packages needed for my Python project to work), and I need to only attempt to install compatible pkgs, so if there are errors, I know they are only from the compatible modules and I should see what happened (not errors also from incompatible pkgs, which I wouldn't care). Example: I'd have wheels for Python 3.5 and 3.7, and in a 3.5 installation, 3.7 wheels could not be tried to be installed.
I've tried pkginfo (https://pypi.org/project/pkginfo/), but on wheel.supported_platforms, it returns an empty array and I can't do anything with that (a wheel with "any" or with "win32" on their name in the platform part, returned an empty array, so I can't use that, it seems).
Also tried the output from python -m pip debug --verbose, but the following appears:
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without no
tice.
This makes the command not possible to use, even though bellow that it prints the "Compatible tags", which more or less I could use to determine if a wheel is supported or not from its name. Example of those "Compatible tags" in a Python array:
['cp39-cp39-win_amd64', 'cp39-abi3-win_amd64', 'cp39-none-win_amd64', 'cp38-abi3-win_amd64', 'cp37-abi3-win_amd64', 'cp36-abi3-win_amd64', 'cp35-abi3-win_amd64', 'cp34-abi3-win_amd64', 'cp
33-abi3-win_amd64', 'cp32-abi3-win_amd64', 'py39-none-win_amd64', 'py3-none-win_amd64', 'py38-none-win_amd64', 'py37-none-win_amd64', 'py36-none-win_amd64', 'py35-none-win_amd64', 'py34-no
ne-win_amd64', 'py33-none-win_amd64', 'py32-none-win_amd64', 'py31-none-win_amd64', 'py30-none-win_amd64', 'cp39-none-any', 'py39-none-any', 'py3-none-any', 'py38-none-any', 'py37-none-any
', 'py36-none-any', 'py35-none-any', 'py34-none-any', 'py33-none-any', 'py32-none-any', 'py31-none-any', 'py30-none-any']
With, for example, "pyHook-1.5.1-cp36-cp36m-win32.whl", I could check the name and see if it's compatible or not (except because of the warning above...).
Any other ideas?
Thanks in advance for any help!
EDIT: I could go manually and pull things from the name and hard-code the some possibilities I see on documentation, like "win32" and "win_amd64" (as I did before), but then I'd need to know exactly all the possibilities that the parts of the name can have (I saw a cool expression on the documentation: "e.g." - which means there are more than the mentioned things) and have a lot of work on that. I was hoping there was already someone that had made such thing (maybe even Python itself has some way in any of its internal packages).
You can do this using packaging.
pip install packaging
An example code to get the tags similar to how you got from pip would be:
from packaging.tags import sys_tags
tags = sys_tags()
print([str(tag) for tag in tags])
# ['cp39-cp39-manylinux_2_33_x86_64', 'cp39-cp39-manylinux_2_32_x86_64', 'cp39-cp39-manylinux_2_31_x86_64', ..... , 'py31-none-any', 'py30-none-any']
Of course, you can do much more things programmatically with the above variable tags:
>>> tags = sys_tags()
>>> for tag in list(tags)[:3]:
... print(tag.interpreter, tag.abi, tag.platform)
...
cp39 cp39 manylinux_2_33_x86_64
cp39 cp39 manylinux_2_32_x86_64
cp39 cp39 manylinux_2_31_x86_64
For more in-depth documentation, check: https://packaging.pypa.io/en/latest/tags.html#packaging.tags.sys_tags

Python / Elaphe generates broken barcodes

I am trying to generate code128 barcodes using Python/Elaphe, which is based on Barcode Writer In Pure Postscript (BWIPP). Strangely, the barcodes generated by Elaphe don't match the ones generated by BWIPP and do not conform to code 128 standard.
In particular, I tried a simple example, the generation of a barcode for the letter 'A' (capital A):
from elaphe import barcode
b = barcode('code128', 'A')
b.show()
That works just fine, but the generated barcode is missing the right part. It is 35 pixels wide, where it should be 46. The left part of the barcode matches the one generated by BWIPP and every other code128 generator - it's only the right section that is missing.
Anyone know what's wrong?
(Using elaphe 0.6.0 with python 2.7.10 on Kubuntu 15.10)
See this bug report:
https://bitbucket.org/whosaysni/elaphe/issues/84/code-128-generation-produces-unreadable
It seems that this bug is fixed in the current source version, also the bug is still marked as new.
The the patch which fixed this bug imho:
https://bitbucket.org/whosaysni/elaphe/commits/19dd8f58c76ac75914e3e4d8ae7db1b9489cbcb8?at=develop
This patch is from the 2014-10-22, the current version elaphe 0.6.0 on pypi is from 2013-12-05. If you installed via pip you have the buggy version.
There is a python3 enabled fork of this project https://pypi.python.org/pypi/elaphe3, which was uploaded on the 2016-05-25. So this fork might contain the necessary bugfix. You could remove elaphe and install elaphe3.
However, considering that elaphe (at least the non 3 version) looks pretty abandoned and has GhostScript and PIL as dependencies I would look for another solution.

Mayavi example fails, crashes python on Ubuntu

I'm trying to run a standard Mayavi example. I just installed mayavi2 on Ubuntu (Kubuntu 12.04) and this is my first step with Mayavi. Unfortunately, this step is failing.
The examples I wish to run come from here:
http://docs.enthought.com/mayavi/mayavi/auto/examples.html
For example, this one.
The behavior I am seeing is that the plot canvas area is blank (mostly). The popup window is shown and its controls are present and working.
The only errors I am seeing are:
libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.
Where would I add LIBGL_DEBUG=verbose?
I'm on Kubuntu 12.04 with:
Python 2.7.3
IPython 1.1.0
wxPython 2.8
vtk 5.8.0-5
setuptools, numpy, scipy - latest versions (just updated)
I am running the examples in IPython (which seems to be the recommended way). I am using this command to start the shell:
ipython --gui=wx --pylab=wx
I also tried running the examples from within an IPython notebook as so:
%run example.py
In all cases the examples fail to display the animation. The window itself is display as are the controls. But the animation canvas is mostly blank, although a flash of the images will sometimes appear.
At least once previously I saw my attempts crash Python. The message was:
The crashed program seems to use third-party or local libraries:
/usr/local/lib/python2.7/dist-packages/traits/ctraits.so
/usr/local/lib/python2.7/dist-packages/tvtk/array_ext.so
However, I am not seeing that crash now.
I found some important clues here:
https://askubuntu.com/questions/283640/libgl-error-failed-to-load-driver-i965
Like that person, I ended up reinstalling my graphics driver and that solved my problem. (The problem wasn't related to mayavi or python after all.)

Difficulty installing and using Mercurial Chart extension

Hi I'm having trouble installing and using the Mercurial ChartExtension
When I installed it as per instructions
First you need to install the extension; type this in your shell:
python ./setup.py install
Blockquote
I then modified my mercurial.ini file as follows
[extensions]
chart=/path/to/chart.py
Blockquote
Then tried running Hg Chart command and got the following error
Can anyone help me get this extension working. I know there's the Hg ActivityExtension as well, but i have not had much luck with that either Problem installing Mercurial Activity extension
A layman's guide to what steps i need to follow would be of immense help
Based on the changelog, the Chart extension has not been updated since late 2008. It would probably work if you tried using it with a version of Mercurial released around that same time (Mercurial v1.1.2 was released on Dec. 30, 2008).
The latest version of Mercurial is now v1.9.2. The API has changed (probably quite a bit) since v1.1.2. If the extension has not been modified to keep up with the changes to the API, then it will fail in ways similar to the error you found. In this case, the number of arguments for the walkchangerevs method has changed.
Updating the extension could be a large task...there is no way to know without inspecting the code. You could try to contact the author (#Ry4an) and ask for help. You could also try to modify the extension yourself.

Categories