Using Windows 10 and Anaconda with Python 3. PyFoam installed with pip.
Python 3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 18:50:55) [MSC v.1915 64 bit (AMD64)] on win32
import PyFoam chrashes with
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\timofey\AppData\Local\Continuum\anaconda3\lib\site-packages\PyFoam__init__.py", line 7, in <module>
from PyFoam.Infrastructure.Configuration import Configuration
File "C:\Users\timofey\AppData\Local\Continuum\anaconda3\lib\site-packages\PyFoam\Infrastructure\Configuration.py", line 85, in <module>
"descriptionPath": eval('["'+path.curdir+'","'+path.join(userDirectory(),"caseBuilderDescriptions")+'","'+path.join(globalDirectory(),"caseBuilderDescriptions")+'"]'),
File "<string>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape</string></module></module></module></stdin>
This is not a new bug, I'm pretty sure it was their at least ever since PyFoam became installable with pip.
As a temporary workaround go to the Configuration.py-file described in the stacktrace and remove
I will have a look whether I have this problem too but probablyy will fix it by removing it. Because
* the use of eval is evil
* pyFoamCaseBuolder is not maintained anymore
but I will look which of the hardcoded values (userDirectory() or globalDirectory() is causing it because these two probably won't work on Windows anyway
Hi!
Is eval really needed, or does it work to just remove the eval and replace with:
The issue is the use of backslash in Windows:
When you put a path with backslash in eval, it fails. E.g.:
Last edit: Erik Sällström 2020-05-15
I in the configurations.py file I edited the userDirectory() and globalDirectory functions in CaseBuilder as to replace the backslashes with /.
Everything worked fine after this. The modules loaded perfectly.
The problem occurs in
userDirectory()on Windows.And the root cause of the problem is "\Uxxxx", which is a unicode escape. Reference
The solution might be this
What about fixing it in
userDirectory()like following?