spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

Spyder Internal Problem (Blowfish deprecated ?) #19975

Open Nagle2036 opened 1 year ago

Nagle2036 commented 1 year ago

Issue Report Checklist

Problem Description

I have been trying to integrate PsychoPy with Spyder, and have been following online instructions to create environments viathe Anaconda prompt through which these two programs can interact. Examples of the code I've been using to do this are:

conda env create -n psychopy -f psychopy-env.yml conda activate psychopy

OR:

conda create -n psychopy python=3.8 anaconda source activate psychopy pip install psychopy

OR:

conda create -n psychopyenv python=3.8 conda install -n psychopyenv pip spyder psychopy conda activate psychopyenv

After all this, Spyder still does not recognise the PsychoPy module. And now, when I open Spyder, an 'Issue reporter' window opens saying that there is an internal problem. Spyder also seems to have 'reset', in that all my altered keyboard shortcuts have returned to default settings and I keep being offered the interactive software tour upon startup, as if I've just downloaded Spyder for the first time.

What steps reproduce the problem?

  1. Opening Spyder.

What is the expected output? What do you see instead?

When opening Spyder from the Anaconda prompt, there are the following lines of errors:

(base) C:\Users\alexn>spyder fromIccProfile: failed minimal tag size sanity C:\Users\alexn\anaconda3\lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated "class": algorithms.Blowfish, Error on reading from the event loop self pipe loop: Traceback (most recent call last): File "C:\Users\alexn\anaconda3\lib\asyncio\windows_events.py", line 453, in finish_recv return ov.getresult() OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\alexn\anaconda3\lib\asyncio\proactor_events.py", line 768, in _loop_self_reading f.result() # may raise File "C:\Users\alexn\anaconda3\lib\asyncio\windows_events.py", line 808, in _poll value = callback(transferred, key, ov) File "C:\Users\alexn\anaconda3\lib\asyncio\windows_events.py", line 457, in finish_recv raise ConnectionResetError(*exc.args) ConnectionResetError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request

Paste Traceback/Error Below (if applicable)


PASTE TRACEBACK HERE

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.3 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.31.1;<8.0.0       :  7.31.1 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.9.0 (OK)
jsonschema >=3.2.0            :  4.16.0 (OK)
keyring >=17.0.0              :  23.4.0 (OK)
nbconvert >=4.0               :  6.4.4 (OK)
numpydoc >=0.6.0              :  1.4.0 (OK)
paramiko >=2.4.0              :  2.8.1 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.0 (OK)
pygments >=2.0                :  2.11.2 (OK)
pylint >=2.5.0;<3.0           :  2.14.5 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.5.0;<1.6.0          :  1.5.0 (OK)
pylsp_black >=1.2.0           :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0     :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.3 (OK)
qtconsole >=5.3.2;<5.4.0      :  5.3.2 (OK)
qtpy >=2.1.0                  :  2.2.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  65.5.0 (OK)
sphinx >=0.6.6                :  5.0.2 (OK)
spyder_kernels >=2.3.3;<2.4.0 :  2.3.3 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
zmq >=22.1.0                  :  23.2.0 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=3.0.0            :  3.5.1 (OK)
numpy >=1.7                   :  1.23.3 (OK)
pandas >=1.1.1                :  1.4.1 (OK)
scipy >=0.17.0                :  1.7.3 (OK)
sympy >=0.7.3                 :  None (NOK)
ccordoba12 commented 1 year ago

Hey @Nagle2036, thanks for reporting. I think you're expecting that Spyder is connected automatically to the psychopy or psychopyenv environments you created to install psychopy, but unfortunately that doesn't happen like that.

To solve this issue, you need to:

  1. Open the Anaconda Prompt and run there:

    conda activate psychopy
    pip install spyder-kernels
  2. Follow our instructions to make the connection I talked about with your psychopy environment.

ccordoba12 commented 1 year ago

Besides, to solve the other problem you have, i.e. this one:

When opening Spyder from the Anaconda prompt, there are the following lines of errors:

(base) C:\Users\alexn>spyder fromIccProfile: failed minimal tag size sanity C:\Users\alexn\anaconda3\lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has >been deprecated "class": algorithms.Blowfish, Error on reading from the event loop self pipe loop: Traceback (most recent call last): File "C:\Users\alexn\anaconda3\lib\asyncio\windows_events.py", line 453, in finish_recv return ov.getresult() OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\alexn\anaconda3\lib\asyncio\proactor_events.py", line 768, in _loop_self_reading f.result() # may raise File "C:\Users\alexn\anaconda3\lib\asyncio\windows_events.py", line 808, in _poll value = callback(transferred, key, ov) File "C:\Users\alexn\anaconda3\lib\asyncio\windows_events.py", line 457, in finish_recv raise ConnectionResetError(*exc.args) ConnectionResetError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request

you need to close Spyder, open the Anaconda Prompt and run there

conda update python

That should work, but let us know if it does for you.

texadactyl commented 1 year ago

@Nagle2036 In addition to the remedy suggested by @ccordoba12 .....

paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated

Yes, blowfish is deprecated in favour of AES. I believe that you are seeing this issue originating from paramikobecause the installed version (2.8.1 - 2021-11-28) is out of date. I would try specifically updating paramiko. The resulting version should be bumped significantly.

Reference: https://www.paramiko.org/changelog.html?highlight=blowfish#2.11.0

Nagle2036 commented 1 year ago

@ccordoba12 and @texadactyl , thank you very much for your responses! It's much appreciated. Your suggestions have worked, and Spyder is no longer opening with an internal error.

The one thing that is still not working is changing the environment to use psychopy within Spyder. After opening the Python Interpreter Preferences, selecting the environment that I have created and activated in the Ananconda Prompt, and clicking 'Apply', I receive an 'Invalid file path' error, even though the path to that environment definitely exists.

Do you have any suggestions on this? Thanks very much again!

spyder_screenshot

Nagle2036 commented 1 year ago

And when starting Spyder from the Anaconda Prompt, it still says Blowfish is deprecated, although not alongside as many errors as before:

(base) C:\Users\alexn>spyder fromIccProfile: failed minimal tag size sanity C:\Users\alexn\anaconda3\lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated "class": algorithms.Blowfish,

texadactyl commented 1 year ago

@Nagle2036 You didn't explain how you updated paramiko. And, I obviously do not know how your machine and O/S are set up.

Python pip packages outside of conda are independent of conda so that probably explains the difference in paramiko versions. Also, independent of pip, the O/S sometimes bundles Python packages when you install O/S packages related to Python.

Unfortunately, mixing pip and conda packages are like gasoline and water. Don't do that. Been there, done that, paid the price! Free advice: do not use pip in conda environments.

What version of paramiko is used in the conda environments you are using?
conda list | grep paramiko conda list -n ENVNAME | grep paramiko

Nagle2036 commented 1 year ago

Hi @texadactyl , thanks for the quick reply.

I updated paramiko using conda update paramiko.

Running conda list | findstr paramiko , it says I have version 2.8.1 Running conda list -n psychopy | findstr paramiko , nothing is returned.

Thanks again for your ongoing help.

texadactyl commented 1 year ago

Somehow, your copy of anaconda/miniconda is using an out of date paramiko. Why? What is your O/S?

I am not using anaconda/miniconda at the moment in Xubuntu Linux. I'll experiment later today with conda when I am free.

Nagle2036 commented 1 year ago

Yes, I'm not sure why my paramiko wouldn't be the most up to date version, especially after explicitly updating it in Anaconda Prompt. My O/S is Windows 10 Home, Version 10.0.19045 Build 19045. I hope that helps.

Do you think that the error here (that I also pasted above) is related to the error that I have in applying the new psychopy environment within Spyder?

(base) C:\Users\alexn>spyder
fromIccProfile: failed minimal tag size sanity
C:\Users\alexn\anaconda3\lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
"class": algorithms.Blowfish,

Thank you!

Alex

texadactyl commented 1 year ago

These are separate anomalies, hence, you have 2 issues.

The vanilla default conda channel is using an old paramiko. See https://anaconda.org/anaconda/paramiko

The conda-forge channel has the correct version of paramiko to use. See https://anaconda.org/conda-forge/paramiko . Don't ask me why the default channel has fallen so far behind! Well, everybody is busy.

To get the conda-forge package instance of paramiko, do this: conda install -c conda-forge paramiko.

Nagle2036 commented 1 year ago

Hi @texadactyl , thanks very much, the paramiko error has gone! I still have the fromIccProfile: failed minimal tag size sanity warning, but I believe I can ignore this.

Do you happen to have any thoughts about my last issue - that I receive an 'Invalid file path' error when trying to change the environment within the Spyder Python Interpreter preferences to psychopy?

Perhaps I need to first install Spyder within the psychopy environment, as I cannot open Spyder from the Anaconda Prompt when in the psychopy environment.

Thanks again! Alex

texadactyl commented 1 year ago

The "fromUccProfile" message is related to Qt so the Spyder folks cannot address this. See https://github.com/spyder-ide/spyder/issues/18026 Yes, ignore it.

Your "'Invalid file path" error when trying to change the environment within the Spyder Python Interpreter preferences to psychopy" issue has nothing to do with this issue. I suggest the following:

Is this what you are trying to do? https://discourse.psychopy.org/t/install-instructions-for-spyder4-on-psychopy3-on-windows/5544

Psychopy has forums: https://discourse.psychopy.org/

ccordoba12 commented 1 year ago

Your "'Invalid file path" error when trying to change the environment within the Spyder Python Interpreter preferences to psychopy" issue has nothing to do with this issue.

That's right, but still this is something we can help @Nagle2036 here.

@Nagle2036, the thing is we run some validations before allowing users to set a Python interpreter so we know that it's an actual interpreter and not another program. To help you with this, please open a terminal (cmd.exe), and run there:

ipython
In [1]: from spyder.utils.programs import is_python_interpreter
In [2]: is_python_interpreter(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")

and report the result here.

Nagle2036 commented 1 year ago

Thanks very much @texadactyl and @ccordoba12 for your patience with this issue!

I ran the code you asked, and it reported False:

(base) C:\Users\alexn>python
Python 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
from spyder.utils.programs import is_python_interpreter
is_python_interpreter(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")
False

Please let me know what the next step might be. Thanks. Alex

ccordoba12 commented 1 year ago

Ok, thanks for your help @Nagle2036. I was expecting that result but I wanted to be sure. Now could you run

from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")

and also in a terminal

C:\Users\alexn\anaconda3\envs\pyschopy\python.exe -c 'import this'

and post both results? Thanks!

Nagle2036 commented 1 year ago

Thanks very much @ccordoba12. Here are the results below:

(base) C:\Users\alexn>python
Python 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\psychopy\python.exe")
False

There was an error running the second command. Not sure how to account for this.

(base) C:\Users\alexn>C:\Users\alexn\anaconda3\envs\psychopy\python.exe -c 'import this'
  File "<string>", line 1
    'import
          ^
SyntaxError: EOL while scanning string literal

Let me know how best to proceed. Thanks. Alex

ccordoba12 commented 1 year ago

Thanks for your patience @Nagle2036. About the second command, please run this instead:

C:\Users\alexn\anaconda3\envs\psychopy\python.exe -c "import this"

I think on Windows you need to use double quotes to run things in the console (and I forgot about it).

Nagle2036 commented 1 year ago

No worries, I've run it again. Must say, I wasn't expecting this output!

(base) C:\Users\alexn>C:\Users\alexn\anaconda3\envs\psychopy\python.exe -c "import this"
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
ccordoba12 commented 1 year ago

Must say, I wasn't expecting this output!

Haha, that's what we use to check if you passed a valid Python interpreter to Spyder.

Now please open the file

C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py

look for the function check_python_help and change this line on it

proc = run_program(filename, ['-c', 'import this'], env={})

to

proc = run_program(filename, ['-c', '"import this"'], env={})

Finally, you need to run again in a terminal

from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")

That should give True and so solve your problem.

Nagle2036 commented 1 year ago

Thank you @ccordoba12. I made the change to the file, but command still returns false unfortunately:

(base) C:\Users\alexn>python
Python 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")
False

As expected, running Spyder and trying to change the environment again still results in an 'Invalid File Path' error. Sorry that this is dragging on!

Cheers Alex

ccordoba12 commented 1 year ago

Ok, could you replace check_python_help in the file I mentioned for this

def check_python_help(filename):
    """Check that the python interpreter can compile and provide the zen."""
    proc = run_program(filename, ['-c', 'import this'], env={})
    stdout, _ = proc.communicate()
    stdout = str(stdout)
    valid_lines = [
        'Beautiful is better than ugly.',
        'Explicit is better than implicit.',
        'Simple is better than complex.',
        'Complex is better than complicated.',
    ]
    if all(line in stdout for line in valid_lines):
        return True
    else:
        return False

and run it again in a new terminal?

That should generate an error that would let us know what's the cause of this problem.

Nagle2036 commented 1 year ago

Hi @ccordoba12 , all done, here it is:

(base) C:\Users\alexn>python
Python 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py", line 1006, in check_python_help
    proc = run_program(filename, ['-c', 'import this'], env={})
  File "C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py", line 274, in run_program
    raise ProgramError("Program %s was not found" % program)
spyder.utils.programs.ProgramError: Program C:\Users\alexn\anaconda3\envs\pyschopy\python.exe was not found

Hope that's helpful. Alex

ccordoba12 commented 1 year ago

Ok, this probably means that you didn't add Anaconda to your PATH environment variable when you installed it. Is that correct?

ccordoba12 commented 1 year ago

Ok, never mind, we should be able to deal with that case. So, please now look for the function run_program in spyder\utils\programs.py and replace the following lines there

fullcmd = find_program(program)
if not fullcmd:
    raise ProgramError("Program %s was not found" % program)

with

if not osp.isfile(program):
    fullcmd = find_program(program)
    if not fullcmd:
        raise ProgramError("Program %s was not found" % program)
else:
    fullcmd = program

and then check again what you get from check_python_help. I think that should work now.

Nagle2036 commented 1 year ago

Hi @ccordoba12 , thanks for this suggestion. I'm not too sure what you mean by adding Anaconda to the PATH environment variable. I made the change in code in the programs.py file, but still returned the same error when running check_python_help:

(base) C:\Users\alexn>python
Python 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py", line 1009, in check_python_help
    proc = run_program(filename, ['-c', 'import this'], env={})
  File "C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py", line 275, in run_program
    raise ProgramError("Program %s was not found" % program)
spyder.utils.programs.ProgramError: Program C:\Users\alexn\anaconda3\envs\pyschopy\python.exe was not found

I don't want to keep taking up your time with this. I can try to just use PsychoPy through its GUI instead of writing the code. If there's any other obvious solution, please let me know. Thanks very much. Alex

ccordoba12 commented 1 year ago

I don't want to keep taking up your time with this.

Don't worry, I don't have a problem with this. The thing is several users have reported a similar problem to yours before and we've been unable to pin it down and fix it because we can't reproduce it on our side.

So, what do you get when run in a terminal?

import os.path as osp
osp.isfile(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")
Nagle2036 commented 1 year ago

Thank you @ccordoba12 ,

I ran the code above and it returned False.

Best wishes, Alex

ccordoba12 commented 1 year ago

Sorry for the long delay to come back to you. What do you get if you run instead

import os.path as osp
osp.exists(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")

?

Nagle2036 commented 1 year ago

Hi @ccordoba12,

No worries! Again, running this code in my terminal returns False.

Best wishes, Alex

ccordoba12 commented 1 year ago

Ok, let's try a different approach because I don't understand what happens here.

Please look again for the function run_program in spyder\utils\programs.py and replace the following lines there

fullcmd = find_program(program)
if not fullcmd:
    raise ProgramError("Program %s was not found" % program)

with

fullcmd = r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe"
#if not fullcmd:
#   raise ProgramError("Program %s was not found" % program)

then open a Python prompt and run again

from spyder.utils.programs import check_python_help
check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")

Perhaps that works this time.

Nagle2036 commented 1 year ago

Hi @ccordoba12

Thanks for this. I replaced the the lines in spyder\utils\programs.py, and ran the code you suggested in my Anaconda prompt, and received the following output:

(base) C:\Users\alexn>python
Python 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from spyder.utils.programs import check_python_help
>>> check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py", line 1009, in check_python_help
    proc = run_program(filename, ['-c', 'import this'], env={})
  File "C:\Users\alexn\anaconda3\lib\site-packages\spyder\utils\programs.py", line 284, in run_program
    return subprocess.Popen(fullcmd, **subprocess_kwargs)
  File "C:\Users\alexn\anaconda3\lib\subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\alexn\anaconda3\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

For the lines that I replaced with in programs.py, did you mean for them to be commented? I've attached a screenshot of where I replaced.

Thanks very much. Alex

Capture

texadactyl commented 1 year ago

@Nagle2036

For whatever it is worth .....

I do not have Windows; I use Xubuntu Linux. Using the following:

My little program:

from spyder.utils.programs import check_python_help
result = check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe") # False
print(result)
result = check_python_help(r"/usr/bin/python3") # True
print(result)

When I run it, I get the expected results and no traceback-crashes:

False
True

It would have been VERY HELPFUL if bloody FileNotFoundError: [WinError 2] The system cannot find the file specified was accompanied by the NAME of what it was unable to find !!!

Anyways, something is obviously is half-baked on your Windows system.

texadactyl commented 1 year ago

Using the Spyder (excellent) debugger, I can see this:

def check_python_help(filename):
    """Check that the python interpreter can compile and provide the zen."""
    try:
        proc = run_program(filename, ['-c', 'import this'], env={})
        stdout, _ = proc.communicate()
        stdout = str(stdout)
        valid_lines = [
            'Beautiful is better than ugly.',
            'Explicit is better than implicit.',
            'Simple is better than complex.',
            'Complex is better than complicated.',
        ]
        if all(line in stdout for line in valid_lines):
            return True
        else:
            return False
    except Exception:
        return False

Suggest you do the same. Step into the following function:

def run_program(program, args=None, **subprocess_kwargs):
    """
    Run program in a separate process.

    NOTE: returns the process object created by
    `subprocess.Popen()`. This can be used with
    `proc.communicate()` for example.

    If 'shell' appears in the kwargs, it must be False,
    otherwise ProgramError will be raised.

    If only the program name is given and not the full path,
    a lookup will be performed to find the program. If the
    lookup fails, ProgramError will be raised.

    Note that stdin, stdout and stderr will be set by default
    to PIPE unless specified in subprocess_kwargs.

    :str program: The name of the program to run.
    :list args: The program arguments.
    :subprocess_kwargs: These will be passed to subprocess.Popen.
    """
    if 'shell' in subprocess_kwargs and subprocess_kwargs['shell']:
        raise ProgramError("This function is only for non-shell programs, "
                           "use run_shell_command() instead.")
    fullcmd = find_program(program)
    if not fullcmd:
        raise ProgramError("Program %s was not found" % program)
    # As per subprocess, we make a complete list of prog+args
    fullcmd = get_full_command_for_program(fullcmd) + (args or [])
    for stream in ['stdin', 'stdout', 'stderr']:
        subprocess_kwargs.setdefault(stream, subprocess.PIPE)
    subprocess_kwargs = alter_subprocess_kwargs_by_platform(
        **subprocess_kwargs)
    return subprocess.Popen(fullcmd, **subprocess_kwargs)

Set a breakpoint at return subprocess.Popen(fullcmd, **subprocess_kwargs). What values are fullcmd and subprocess_kwargs set to?

texadactyl commented 1 year ago

On my system, they are set up as expected and the subprocess, as reported earlier, runs as expected.

ccordoba12 commented 1 year ago

Set a breakpoint at return subprocess.Popen(fullcmd, **subprocess_kwargs). What values are fullcmd and subprocess_kwargs set to?

That's a good idea @Nagle2036. Let us know what you get.

Nagle2036 commented 1 year ago

Thanks @texadactyl and @ccordoba12

Apologies in advance if I didn't understand these instructions correctly. In the def check_python_help(filename) command, I saw that my version was not wrapped by the try: and except Exception: lines, so I added these in.

I then went into def run_program, set a breakpoint at the last line as you asked, and ran the file from within Spyder. Was I meant to see values for fullcmd and subprocess_kwargs in the variable explorer and pass them to you? I couldn't see them.

In the code, fullcmd and subprocess_kwargs are set to the same as what you have pasted above.

Hope that's somewhat helpful. Thanks. Alex

texadactyl commented 1 year ago

No, you were just supposed to verify that the values of fullcmd and subprocess_kwargs make sense. Don't change the code. What are the values (Variable Explorer) when you reach the breakpoint?

Also, it sounds like your copy of spyder.utils.programs is not current. When was the last time that you updated spyder? Ditto for the other Python library modules.

texadactyl commented 1 year ago

Looking back at your problem description, I am concerned that you may have "mixed gaoline and water". Spyder and many other projects caution us to avoid mixing conda and pip whenever possible. After looking at both Anaconda and pip code, I can see why.

When I install Anaconda (or Miniconda) + Spyder, I have never had an issue with Spyder. If I need to add a non-Anaconda package with pip, I create a special environment for that purpose, activate it , and only do my pip install operations there. In that way, I keep the Anaconda base and other environments clean of pip manipulation. When done with a pip-modified Anaconda environment, one can safely remove it.

This should work after installing Anaconda or Miniconda:

conda create -n psychopy
source activate psychopy
pip install psychopy

If you wish to import psychopy stuff in a Spyder development tab (develop + edit + debug etc.), be sure to start Spyder only when the psychopy envirnment is active.

Yes, it is a royal pain that in 2022 there are STILL 2 conflicting package managers for Python.

vmantyne commented 1 year ago

Are you guys sure this interpreter issue is not related to a typo in the path? @ccordoba12

If I read right @Nagle2036 created environment psychopy.

conda create -n psychopy

But most if not all of tests are applied on pyschopy.

from spyder.utils.programs import check_python_help check_python_help(r"C:\Users\alexn\anaconda3\envs\pyschopy\python.exe")

That would explain why the interpreter validation failed also after adding (Windows) double quotes in the code.

haidermir0012 commented 1 year ago

got the same issue, on windows 10, it was working before but now it gives me the same error as mentioned above.

fromIccProfile: failed minimal tag size sanity C:\Users\Lenovo\anaconda3\envs\ncl\Lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated "class": algorithms.Blowfish, Bad address (C:\ci\zeromq_1616055400030\work\src\epoll.cpp:100) Traceback (most recent call last): File "C:\Users\Lenovo\anaconda3\envs\ncl\Lib\asyncio\windows_events.py", line 444, in select self._poll(timeout) RuntimeError: <_overlapped.Overlapped object at 0x00000264CF008B70> still has pending operation at deallocation, the process may crash Bad address (C:\ci\zeromq_1616055400030\work\src\epoll.cpp:100) Bad address (C:\ci\zeromq_1616055400030\work\src\epoll.cpp:100) Traceback (most recent call last): File "C:\Users\Lenovo\anaconda3\envs\ncl\Lib\asyncio\windows_events.py", line 444, in select self._poll(timeout) RuntimeError: <_overlapped.Overlapped object at 0x00000264CF008B70> still has pending operation at deallocation, the process may crash Traceback (most recent call last): File "C:\Users\Lenovo\anaconda3\envs\ncl\Lib\asyncio\windows_events.py", line 444, in select self._poll(timeout) RuntimeError: <_overlapped.Overlapped object at 0x00000264CF009830> still has pending operation at deallocation, the process may crash Bad address (C:\ci\zeromq_1616055400030\work\src\epoll.cpp:100).

I tried all the possible ways mentioned on internet, like updating, reinstalling the Anaconda, even reinstalled the windows, 10, 11 and 11pro. still, failed to resolve the issue.