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

This version of python seems to be incorrectly compiled message with Python 3.11 from Anaconda #20800

Closed
James910-code opened this issue Apr 11, 2023 · 21 comments

Comments

@James910-code
Copy link

James910-code commented Apr 11, 2023

  • Console banner:
Python 3.11.2 | packaged by Anaconda, Inc. | (main, Mar 27 2023, 23:35:04) [MSC v.1916 64 bit (AMD64)]Type "copyright", "credits" or "license" for more information.IPython 8.10.0 -- An enhanced Interactive Python
  • Message:
This version of python seems to be incorrectly compiled(internal generated filenames are not absolute).This may make the debugger miss breakpoints.Related bug: http://bugs.python.org/issue1666807.

For example restart the kernel to see it:

Restarting kernel..
@dalthviz
Copy link
Member

Hi @James910-code, could you provide more info about your setup? What Spyder version you have installed? Could it be that you updated you anaconda base environment Python version to be 3.11.2 and that started causing the issue?

Without more info there is not much we can due to help, sorry :/ But maybe a look to the Spyder installation guide could help: https://docs.spyder-ide.org/current/installation.html#conda-based-distributions

Let us know if the installation guide helps!

@zach-morris
Copy link

I have the same issue, so I'll include my info here.
Fresh install of spyder via conda:
Env yml was:

name: myenv
dependencies:
- python>=3.11
- spyder
- pip
- pip:
  - -r requirements.txt 

Generated the environment with:

conda env create -f "C:\xxx\my_environment.yml"

With no issues.

>conda --version
conda 22.9.0
>conda list
...
python                    3.11.3               h966fe2a_0
...
spyder                    5.4.3           py311haa95532_1
spyder-kernels            2.4.3           py311haa95532_0
...
>python --version
Python 3.11.3

If I run any command via the IDE i get the warning:

In [1]: print('test')
test

This version of python seems to be incorrectly compiled
(internal generated filenames are not absolute).
This may make the debugger miss breakpoints.
Related bug: http://bugs.python.org/issue1666807

If I run the same script or command via the python / command line it runs without error.

@zach-morris
Copy link

zach-morris commented Apr 21, 2023

~~Edit. I see the problem now. The version of python I have in my 'base' environment is different than the version in my other environments.
If i go to the preferences in spyder, i can change the python interpreter to be the one for that specific environment instead of the default and the error is removed.

I would assume the default interpreter would be the same one as the environment that spyder is being run in. Why would it be different?~~
See below comment, this doesn't seem to solve the issue for me.

@dalthviz
Copy link
Member

Hi @zach-morris thank you for the info! So you are launching Spyder from the new env and only when setting the custom Python interpreter option to the Python interpreter of the env from where Spyder was launched the message stops appearing?

Maybe something is happening with the activation of the default environment with Python 3.11 (which should be the Python interpreter of the activated env where Spyder was launched as you mentioned) 🤔 What do you think @ccordoba12 ?

@ccordoba12
Copy link
Member

I think we need a more detailed series of steps from @zach-morris (which is what you requested from him) to understand how to reproduce this problem. Otherwise, we won't be able to solve it.

@zach-morris
Copy link

zach-morris commented Apr 21, 2023

Well, i take that back. The message is intermittent even if I set the interpreter manually. I'm unable to determine the cause or a workaround.
Steps are spelled out:

  • New install of conda version 22.9.0
  • Create new conda environment via (yml is listed above, everything is pretty generic, although I install several packages via pip):
conda env create -f "C:\xxx\my_environment.yml"
  • Start spyder with default settings. Note that the bottom status bar of spyder denotes the correct environment and python version
  • Run any code (i.e print('test')) and recieve the error

The other thing I will say is that I had to uninstall anaconda and re-install the new version recently. Unsure if there are spyder settings hidden somewhere within windows outside of the anaconda environment that I should purge to see if that is causing the issue.

@dalthviz
Copy link
Member

Could you try to create the env with Python < 3.11 and see if the message still appears? Let us know!

@zach-morris
Copy link

Ok, here are the requested test:

Test Env 1 yml:

name: test_env1
dependencies:
- python=3.10
- spyder
- pip

Test Env 2 yml:

name: test_env2
dependencies:
- python>=3.11
- spyder
- pip

Commands run:

(base) C:\Users\xxxx>conda env create -f "C:\tools\test_env1.yml"
Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages
...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate test_env1
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Retrieving notices: ...working... done

(base) C:\Users\xxxx>conda env create -f "C:\tools\test_env2.yml"
Collecting package metadata (repodata.json): done
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate test_env2
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Retrieving notices: ...working... done

(base) C:\Users\xxxx>conda activate test_env1

(test_env1) C:\Users\xxxx>spyder

** See screenshot 1 **

(test_env1) C:\Users\xxxx>conda activate test_env2

(test_env2) C:\Users\xxxx>spyder

** See screenshot 2 **

Screenshot 1 (python 3.10.11):
Capture1

Screenshot 2 (python 3.11.3):
Capture2

@dalthviz
Copy link
Member

So seems like the issue is related with Python 3.11. Could you set this env variable and check if the message continues?:

PYDEVD_DISABLE_FILE_VALIDATION=1

@zach-morris
Copy link

Setting that variable and then running the following command in spyder:

import os; os.environ.get('PYDEVD_DISABLE_FILE_VALIDATION')
Out[1]: '1'
This version of python seems to be incorrectly compiled
(internal generated filenames are not absolute).
This may make the debugger miss breakpoints.
Related bug: http://bugs.python.org/issue1666807

@dalthviz
Copy link
Member

Checked locally and was able to reproduce this 👍 Also, creating the env with packages from the conda-forge channel prevents this message 🤔

Checking a little bit more the Python issue linked in the message, seems like if you add to the command that Spyder uses to launch the console kernel a -Xfrozen_modules=off flag the message stops. The change can be done at:

kernel_cmd = [
pyexec,
'-m',
'spyder_kernels.console',
'-f',
'{connection_file}'
]

So the code ends up being something like:

            kernel_cmd = [
                pyexec,
                '-Xfrozen_modules=off',
                '-m',
                'spyder_kernels.console',
                '-f',
                '{connection_file}'
            ]

The comment that suggest the use of the -Xfrozen_modules=off flag: https://bugs.python.org/issue1666807#msg416932

@zach-morris
Copy link

zach-morris commented Apr 22, 2023

Confirmed thats a good workaround. Seems like it would need to be fixed upstream but the upstream issues are closed? If thats the case, this might need to be permanently added into spyder to avoid the issue. Related issues:
python/cpython#44604
fabioz/PyDev.Debugger#213

@dalthviz dalthviz changed the title This version of python seems to be incorrectly compiled(internal generated filenames are not absolute).This may make the debugger miss breakpoints.Related bug: http://bugs.python.org/issue1666807Python 3.11.2 | packaged by Anaconda, Inc. | (main, Mar 27 2023, 23:35:04) [MSC v.1916 64 bit (AMD64)]Type "copyright", "credits" or "license" for more information.IPython 8.10.0 -- An enhanced Interactive Python.Restarting kernel.. This version of python seems to be incorrectly compiled (internal generated filenames are not absolute) message with Python 3.11 from default anaconda channel installation Apr 24, 2023
@dalthviz dalthviz added this to the v5.4.4 milestone Apr 24, 2023
@dalthviz
Copy link
Member

Thank you for the confirmation and extra links @zach-morris ! I think we could try to add the extra flag mentioned checking if the interpreter is running Python 3.11. What do you think @ccordoba12 ? Is there any other way to suppress that message from appearing?

@ccordoba12
Copy link
Member

What do you think @ccordoba12 ?

I think that's a good idea. Thanks for tracking the problem down and finding a solution @dalthviz! Please go ahead and implement it.

Since Guido himself proposed the same solution in the PyDev.Debugger repo, it doesn't appear to be harmful. In addition, we don't use nor depend on the PyDev debugger, so I'm not expecting major issues with this change.

@ccordoba12 ccordoba12 changed the title This version of python seems to be incorrectly compiled (internal generated filenames are not absolute) message with Python 3.11 from default anaconda channel installation This version of python seems to be incorrectly compiled message with Python 3.11 from Anaconda May 20, 2023
@Taha0229
Copy link

Taha0229 commented Aug 5, 2023

can someone exactly

Checked locally and was able to reproduce this 👍 Also, creating the env with packages from the conda-forge channel prevents this message 🤔

Checking a little bit more the Python issue linked in the message, seems like if you add to the command that Spyder uses to launch the console kernel a -Xfrozen_modules=off flag the message stops. The change can be done at:

kernel_cmd = [
pyexec,
'-m',
'spyder_kernels.console',
'-f',
'{connection_file}'
]

So the code ends up being something like:

            kernel_cmd = [
                pyexec,
                '-Xfrozen_modules=off',
                '-m',
                'spyder_kernels.console',
                '-f',
                '{connection_file}'
            ]

The comment that suggest the use of the -Xfrozen_modules=off flag: https://bugs.python.org/issue1666807#msg416932

I am very new to jupyter notebook and I am not getting how to fix the error as you mentioned. Can someone please help me out, like where to navigate to alter the spyder code.

@yanyu2015
Copy link

the same error happens after customizing the interpretation with version 5.4.3

@ccordoba12
Copy link
Member

@Taha0229, @yanyu2015, this problem was fixed in our latest version (5.4.4), which is not available in Anaconda yet. In the meantime, you can safey ignore that message because it's simply a warning and doesn't affect Spyder in any way.

@Sheetal-11
Copy link

I opened Anaconda Prompt using "Run as Administrator" and then I ran this command:

conda update conda

And it fixed this problem for me.

@PhilipYip1988
Copy link

PhilipYip1988 commented Aug 17, 2023

There seems to be a newer Anaconda 2023-07-2 installer that is updated to Python 3.11.4 whereas the previous 2023-07-01 and 2023-07-0 used Python 3.11.3 as far as I can tell it has also resolved the issue despite it being the same version of Spyder 5.4.3:

https://docs.anaconda.com/free/anaconda/reference/release-notes/#anaconda-2023-07-2-august-04-2023

@ccordoba12
Copy link
Member

Ok, that's great news! Thanks @PhilipYip1988 for letting us know about it.

@sanisalisu
Copy link

hello every one, I thank all of you for your contribution . But I still cannot my spyder to implement SURF and SIFT. Please I need your HELP.

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

No branches or pull requests

9 participants