-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Can't use pythonw as interpreter when needed on Mac #7059
Comments
Thanks for reporting. We'll try to fix this in our next release. |
@dalthviz, please work on this one. Users should be able to use |
I still have the same problem. I changed the files "programs.py" and "test_programs.py" according to the instructions but I get the same error message when I want to change the interpreter: Preferences---> Python Interpreter -> pythonw. I think the problem is that the above files do not consider OS X (or the output of os.name which is posix for OS X). Any comment? |
Yes, please see the milestone: this is for Spyder 3.3, which hasn't been released yet. |
Hi @superashtex so you tried changing the files with the changes made in #7170 and that didn't work for you? Did you restart Spyder after changing the files? |
Hi @dalthviz, yes I did it several times. I also restarted the computer. No effect. I also tweaked the code a bit and added this line in the first "if" loop in "test_programs.py": VALID_W_INTERPRETER = os.path.join(home_dir, 'anaconda3', 'bin', 'pythonw') Moreover, I removed all "os.environ.get('CI', None)" in "skipif" lines. No effect either. I guess I will have to run my wxPython codes directly using pythonw in a terminal or buy a Windows laptop (which I despise)! Thanks |
Um then our approach doesn't actually fix the problem. I don't have a Mac so is difficult to test this but let us work on it. You shouldn't need to get Windows just for this to work :) |
That would be great! Let's do it! |
Maybe the validation that is failing is the one at @superashtex could you run this little app in Spyder and check the options in the menu bar to see if they show import sys
import os.path as osp
from qtpy.QtCore import QSize, Qt
from qtpy.QtWidgets import (QApplication, QMainWindow, QLabel,
QGridLayout, QMessageBox, QWidget)
from spyder.utils.programs import is_python_interpreter, run_program
class HelloWindow(QMainWindow):
PATH_TO_INTERPRETER = "C:/Users/Daniel/Anaconda3/pythonw.exe"
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(400, 100))
self.setWindowTitle("Hello world")
w = QWidget(self)
self.setCentralWidget(w)
gridLayout = QGridLayout(self)
w.setLayout(gridLayout)
title = QLabel("Hello World from PyQt", self)
title.setAlignment(Qt.AlignCenter)
gridLayout.addWidget(title, 0, 0)
menu = self.menuBar().addMenu('is_python_interpreter')
valid1 = menu.addAction('is_python_interpreter')
valid1.triggered.connect(self.is_valid_python_inter)
menu = self.menuBar().addMenu('warn_compatibility')
valid2 = menu.addAction('warn_compatibility')
valid2.triggered.connect(self.warn_python_compatibility)
def is_valid_python_inter(self):
"""Check if is valid"""
QMessageBox.information(self,
"Is valid?",
str(is_python_interpreter(
self.PATH_TO_INTERPRETER)
)
)
def warn_python_compatibility(self):
"""Warning compatibibility"""
pyexec = self.PATH_TO_INTERPRETER
if not osp.isfile(pyexec):
return
spyder_version = sys.version_info[0]
try:
args = ["-c", "import sys; print(sys.version_info[0])"]
proc = run_program(pyexec, args)
console_version = int(proc.communicate()[0])
except IOError:
console_version = spyder_version
except ValueError:
QMessageBox.information(self,
"Is valid?",
str(False)
)
if spyder_version != console_version:
QMessageBox.warning(
self, 'Warning',
("You selected a <b>Python %d</b> interpreter for the console "
"but Spyder is running on <b>Python %d</b>!.<br><br>"
"Although this is possible, we recommend you to install and "
"run Spyder directly with your selected interpreter, to avoid"
"seeing false warnings and errors due to the incompatible "
"syntax between these two Python versions."
) % (console_version, spyder_version), QMessageBox.Ok)
QMessageBox.information(self,
"Is valid?",
str(True)
)
if __name__ == "__main__":
def runapp():
app = QApplication(sys.argv)
main = HelloWindow()
main.show()
app.exec_()
runapp() |
@dalthviz, this probably happens in macOS because pythonw is not a binary file and so it gets rejected by our initial validation. |
wxPython is not working in anacoda (macOS).. |
This is a problem again in Spyder 4.2.1. It does not allow pythonw to be selected as a python interpreter |
Problem Description
When I try to run a wxPython script (such as the example below) from within spyder, I get this error:
The normal solution is to run the script in pythonw (from anaconda python.app package). FWIW, the shell script to start spyder itself is running pythonw via the shebang.
When I try to use the "Preferences/Python interpreter" command to change to pythonw, it will not accept that change with error message:
Package Versions
Dependencies
The text was updated successfully, but these errors were encountered: