Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unintelligible codes #155

Open
yangtzech opened this issue Jun 23, 2021 · 6 comments
Open

unintelligible codes #155

yangtzech opened this issue Jun 23, 2021 · 6 comments

Comments

@yangtzech
Copy link

When the matlab code is wrong, the tips can't show correctly.
My pc's default language is Chinese. I don't know if that's the reason.

wrong one:
x=1:1:100; y=10*x*x; plot(x,y) title('test')

correct one:
x=1:1:100; y=10*x.*x; plot(x,y) title('test')

tip:
image

@RibomBalt
Copy link
Contributor

Hi, this seems to be something to do with encoding. Which Python version are you using?
I recall that "MATLAB engine for Python" supports python 2.7, which might cause problems when encountering Unicode Characters (like Chinese characters), but there should be no problems with Python 3.x versions.

@yangtzech
Copy link
Author

Hi, this seems to be something to do with encoding. Which Python version are you using? I recall that "MATLAB engine for Python" supports python 2.7, which might cause problems when encountering Unicode Characters (like Chinese characters), but there should be no problems with Python 3.x versions.

It seemed to be python 3.8 and MATLAB 2020b. I just tried it again and the error could display correctly this time with python 3.8 and MATLAB 2021b. Thanks for your help anyway!

@allefeld
Copy link

allefeld commented Mar 25, 2023

I encountered a similar problem: fprintf('→\n') produces an entirely different symbol in the output.

image

That symbol is "Non-printable U+001A".

Here is the produced cell:

  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001a\n"
     ]
    }
   ],
   "source": [
    "fprintf('→\\n')"
   ]
  },

My system:
Debian GNU/Linux 11.6, kernel 5.10.0-21-amd64
Locale LANG=en_US.UTF-8.
MATLAB 9.13.0.2166757 (R2022b) Update 4
Python 3.10

@allefeld
Copy link

allefeld commented Jul 13, 2023

The problem seems to be related to MatlabKernel._execute_async. An extremely hacky workaround is to comment out the import of pipes from wurlitzer in kernel.py:

# try:
#     from wurlitzer import pipes
# except Exception:
#     pipes = None
pipes = None

@allefeld
Copy link

Dug a little deeper: The problem is caused by a bug in the Matlab engine for Python:

mathworks/matlab-engine-for-python#34

@dsblank
Copy link
Member

dsblank commented Sep 12, 2023

Thanks @allefeld for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants