'Spyder sys.argv error: NameError: name 'basestring' is not defined
UPDATE (2022-03-02): I discovered another nasty error. The Spyder IDE debugger doesn't work either. :-( The error is another namespace error (similar, but different from error below). I'm beginning to think I have a conflict from a package I installed last week.
TypeError: runfile() got an unexpected keyword argument 'current_namespace'
I have used Spyder IDE for several years without problems. Today I experienced a error with sys.argv usage in the IDE (only). (This is in a script I run several times a month over the past year.) I am trying to diagnose how/why this popped up. I have not change my Spyder installation (at least not intentionally). I recently installed the cartopy package and installed/removed basemap package. Spyder configuration:
E:\kcw78> list spyder
# packages in environment at C:\anaconda\Miniconda3:
# Name Version Build
pyls-spyder 0.3.2 pyhd3eb1b0_0
spyder 4.2.0 py38haa95532_0
spyder-kernels 1.10.2 py38haa95532_0
Simple test code:
import sys
print(len(sys.argv))
print(sys.argv)
Behavior:
The script runs as expected when I execute it in a command window (w/ or w/out arguments).
Output below:
E:\kcw78> python test_sysargv.py
1
['test_sysargv.py']
E:\kcw78> python test_sysargv.py testval
2
['test_sysargv.py', 'testval']
I get different behavior when I run in the Spyder IDE.
It works if I don't enter any command line options (under Run/Configuration per file).
However, I get an error when I enter a value in Command line options. Error message in IPython console window:
runfile('E:/kcw78/test_sysargv.py', args='name.txt', wdir='E:/kcw78')
Traceback (most recent call last):
File "C:\Windows\TEMP/ipykernel_5888/3729903912.py", line 1, in <module>
runfile('E:/kcw78/test_sysargv.py', args='name.txt', wdir='E:/kcw78')
File "C:\anaconda\Miniconda3\lib\site-packages\debugpy\_vendored\pydevd\_pydev_bundle\pydev_umd.py", line 147, in runfile
if args is not None and not isinstance(args, basestring):
NameError: name 'basestring' is not defined
Any suggestions why I get different behavior for execution in Spyder vs command line? For example, configuration settings to check?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
