Error while running a python script in Spyder - python

I have installed Anaconda (Python 2.7) in Windows 7. Initially, it was a bit problematic to start spyder, but eventually I figured out that by running cmd as administrator, spyder starts. As soon as I ran my first python script in Spyder, it showed me an error in its internal console:
F:\PythonIDE\lib\site-packages\nbformat\current.py:19: UserWarning: nbformat.current is deprecated.
- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
""")
F:\PythonIDE\lib\pkgutil.py:110: FutureWarning: The pandas.rpy module is deprecated and will be removed in a future version. We refer to external packages like rpy2.
See here for a guide on how to port your code to rpy2: http://pandas.pydata.org/pandas-docs/stable/r_interface.html
__import__(name)
F:\PythonIDE\lib\site-packages\matplotlib\cbook.py:137: MatplotlibDeprecationWarning: The matplotlib.delaunay module was deprecated in version 1.4. Use matplotlib.tri.Triangulation instead.
warnings.warn(message, mplDeprecation, stacklevel=1)
F:\PythonIDE\lib\site-packages\skimage\filter\__init__.py:6: skimage_deprecation: The `skimage.filter` module has been renamed to `skimage.filters`. This placeholder module will be removed in v0.13.
warn(skimage_deprecation('The `skimage.filter` module has been renamed '
Failed to write user configuration file.
Please submit a bug report.
Traceback (most recent call last):
File "F:\PythonIDE\lib\site-packages\spyderlib\plugins\editor.py", line 2066, in run_file
dialog.setup(fname)
File "F:\PythonIDE\lib\site-packages\spyderlib\plugins\runconfig.py", line 349, in setup
self.runconfigoptions = RunConfigOptions(self)
File "F:\PythonIDE\lib\site-packages\spyderlib\plugins\runconfig.py", line 148, in __init__
self.runconf = RunConfiguration()
File "F:\PythonIDE\lib\site-packages\spyderlib\plugins\runconfig.py", line 57, in __init__
self.set(CONF.get('run', 'defaultconfiguration', default={}))
File "F:\PythonIDE\lib\site-packages\spyderlib\userconfig.py", line 387, in get
self.set(section, option, default)
File "F:\PythonIDE\lib\site-packages\spyderlib\userconfig.py", line 446, in set
self._save()
File "F:\PythonIDE\lib\site-packages\spyderlib\userconfig.py", line 136, in _save
raise(e)
WindowsError: [Error 5] Access is denied: u'C:\\Users\\Shubhanshu\\.spyder2\\spyder.ini'
Now, how to rectify this error? I would be really grateful for any help in this regard.

Related

Spyder keeps crashing during load in all Anaconda environment

I was running python 2.7 in Anaconda2 in spyder 4 up until today with no problems. But now I keep getting the same error, when I make an environment and install python 2.7 and spyder in it:
Traceback (most recent call last):
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3718, in main
mainwindow = run_spyder(app, options, args)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3557, in run_spyder
main = MainWindow(options)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 426, in init
from spyder.preferences.runconfig import RunConfigPage
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/preferences /runconfig.py", line 482, in
class RunConfigPage(GeneralConfigPage):
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/preferences/runconfig.py", line 487, in RunConfigPage
ICON = ima.icon('run')
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/utils/icon_manager.py", line 394, in icon
directory=_resource['directory'])
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/init.py", line 178, in load_font
return _instance().load_font(prefix, ttf_filename, charmap_filename, directory)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/init.py", line 54, in _instance
'materialdesignicons-webfont-charmap.json')
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/iconic_font.py", line 206, in init
super().init()
TypeError: super() takes at least 1 argument (0 given)
This started happening after I reinstalled the package "pydicom" in the environment, and now nothing works. I have reinstalled anaconda2, used spyder --reset, and all other common suggestions.
Spyder 3.3.6 works in the base environment, but every time I make a new environment and install spyder in this, I get the same error. Any suggestions?
(Spyder maintainer here) To fix this problem, you need to install QtAwesome 0.7.3 in your environment. For that, please use the following command:
conda install qtawesome=0.7.3

Debugging python code in pycharm

This question is similar to this one. I am trying to debug pyethapp
with the following configuration:
The entry point is located in app.py. The code runs fine when not being debugged, but once I launch the debugger the following exception is thrown:
Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt
/usr/local/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
% self._get_c_name())
Traceback (most recent call last):
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "app.py", line 27, in <module>
from console_service import Console
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "console_service.py", line 38, in <module>
#inputhook_manager.register('gevent')
AttributeError: 'InputHookManager' object has no attribute 'register'
The solution suggested here (reinstalling ipython) did not solve the issue (it occurs only when debugging; the client works when run separately).
Edit:
Command line in output:
/usr/bin/python2.7 /home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support --client 127.0.0.1 --port 59087 --file app.py --profile testnet --data-dir testnetState/ run
warning: Debugger speedups using cython not found. Run '"/usr/bin/python2.7" "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/setup_cython.py" build_ext --inplace' to build.
pydev debugger: process 20493 is connecting
Connected to pydev debugger (build 145.260)
Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt
/usr/local/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
% self._get_c_name())
Traceback (most recent call last):
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "app.py", line 27, in <module>
from console_service import Console
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "console_service.py", line 38, in <module>
#inputhook_manager.register('gevent')
AttributeError: 'InputHookManager' object has no attribute 'register'
This error is known to happen if you use old versions of IPython (in which indeed the method register was not yet implemented). As you presumably use OSX, in which a default Python install is included, there might be some conflicting Ipython copies in your environment, different versions of which are called by the regular and debugging configurations?
This problem is probably resolved by moving the project to a virtual environment in which your root packages cannot interfere.
To get rid of cython missing warning, run:
python2 /.......git/liclipse/plugins/org.python.pydev_6.2.0.201711281546/pysrc/setu p_cython.py build_ext --inplace
Finally the debug window stay clean of those dreaded warnings and cluttering.

Spyder won't connect to kernel / iPython console

Since my laptop crashed (for unknown reason) last night, Spyder has not been able to connect to a kernel. I am getting this error:
IOError: Could not find u'kernel-1809.json' in ['.', '~/Library/Jupyter/runtime']
(The name of the json file changes each time I attempt to launch an iPython console.)
This does not seem to be related to the matplotlib 1.5 issue, that I have seen elsewhere on here - it is using 1.4.3.
iPython (version 4.0.0) runs fine from the command line.
Mac 10.10.1 (Yosemite). Spyder 2.3.7. Python 2.7.10 64bits, Qt 4.8.7, PyQt4 (API v2) 4.11.3 on Darwin
UPDATED TO INCLUDE LOGS
>>> /Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/nbformat/current.py:19: UserWarning: nbformat.current is deprecated.
- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
ERROR: 3rd party plugin import failed for `p_pylint`
Traceback (most recent call last):
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/otherplugins.py", line 53, in get_spyderplugins_mods
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderplugins/p_pylint.py", line 23, in <module>
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderplugins/widgets/pylintgui.py", line 71, in <module>
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderplugins/widgets/pylintgui.py", line 61, in get_pylint_version
File "subprocess.pyc", line 710, in __init__
File "subprocess.pyc", line 1335, in _execute_child
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/plugins/externalconsole.py", line 925, in <lambda>
give_focus=give_ipyclient_focus))
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/plugins/externalconsole.py", line 1033, in register_ipyclient
give_focus=give_focus)
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/plugins/ipythonconsole.py", line 836, in register_client
self.connect_client_to_kernel(client)
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/plugins/ipythonconsole.py", line 1048, in connect_client_to_kernel
client.password)
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/plugins/ipythonconsole.py", line 1017, in create_kernel_manager_and_client
cf = find_connection_file(connection_file)
File "/Volumes/Spyder-Py2/Spyder-Py2.app/Contents/Resources/lib/python2.7/jupyter_client/connect.py", line 185, in find_connection_file
raise IOError("Could not find %r in %r" % (filename, path))
IOError: Could not find u'kernel-2018.json' in ['.', u'/Users/garyspatterson/Library/Jupyter/runtime']
** Further update **
I deleted all files under the .spyder2/ folder in my user directory, reopened Spyder, and it was able to connect to an iPython console. So far, so good. Trouble is, when I added a path to the PYTHONPATH manager (so I could import external modules, such as nltk), I am back to getting the same error.
Had a similar issue and was able to resolve it by creating a new virtualenv with the same dependencies installed.
Now Spyder is working with the PYTHONPATH pointing at lib/python2.7/site-packages of the new environment.

Python help('modules') command throws WindowsError in IDLE (idle.pyw) but not command line prompt (python.exe)

If I type the following at the python.exe command prompt...
>>>help('modules')
...I get a list of available modules as expected.
However when I type the same thing in the IDLE environment (idle.pyw), it throws an error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
help('modules')
File "C:\Python27\ArcGIS10.1\lib\site.py", line 467, in __call__
return pydoc.help(*args, **kwds)
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1727, in __call__
self.help(request)
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1766, in help
elif request == 'modules': self.listmodules()
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1887, in listmodules
ModuleScanner().run(callback, onerror=onerror)
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1938, in run
for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
File "C:\Python27\ArcGIS10.1\lib\pkgutil.py", line 105, in walk_packages
for importer, name, ispkg in iter_modules(path, prefix):
File "C:\Python27\ArcGIS10.1\lib\pkgutil.py", line 147, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "C:\Python27\ArcGIS10.1\lib\pkgutil.py", line 211, in iter_modules
for fn in os.listdir(path):
WindowsError: [Error 5] Access is denied: 'C:\\WINDOWS\\system32\\Msdtc/*.*'
Why does Windows say "Access is denied" to IDLE but not the command line? I have tried using "Run as Administrator" on IDLE without success. Do I need to reconfigure IDLE in some way?
For information:
My installation of Python 2.7.2 (32-bit version running on a Windows 7 64-bit machine) came bundled with ArcGIS 10.1, which uses Python as a scripting language and certain numerical operations (via Numpy). Could this have something to do with the differing behaviour in the prompt and IDLE?
The root Python directory is: C:\Python27\ArcGIS10.1\.
IDLE is installed at C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw.
The Python command prompt is installed at: C:\Python27\ArcGIS10.1\python.exe.
I just successfully ran help('modules') in both 2.7.8 and 3.4.2. The response depends on sys.path. It appears than ArcGIS adds C:/Windows/System32/Msdtc to the path, but you could check before running help. In any case, accessing that folder cannot be done through Windows Explorer, even when running as an admin. It requires special user action through a 'security tab'. Since MS does not want me poking around there, I did not pursue getting access. I don't know why the difference betweeon console and Idle.

Mercurial CGI (hgweb.cgi) fails

I have Mercurial 1.8.1, Python 2.6.6 installed on Win 2k8 R2 running on a vm. I have tried installing from msi, source and using tortisehg. Command-line Hg works fine but I get the same error when running the hgweb.cgi:
Traceback (most recent call last):
File ".\hgweb.cgi", line 17, in
application = hgweb(config)
File "mercurial\hgweb\__init__.pyc", line 26, in hgweb
File "mercurial\hgweb\hgwebdir_mod.pyc", line 61, in __init__
File "mercurial\hgweb\hgwebdir_mod.pyc", line 70, in refresh
File "mercurial\ui.pyc", line 35, in __init__
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\util.pyc", line 576, in
File "mercurial\demandimport.pyc", line 85, in _demandimport
File "mercurial\windows.pyc", line 21, in
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\osutil.pyc", line 12, in
File "mercurial\osutil.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
The other answers I have found on SO and elsewhere pointed me to try installing from source, dropping the pure osutil into the install, or installing an older version. I have tried them all.
This is especially frustrating because I have other, similar non-vm machines running fine but have been unable to find the disconnect.
Ideas?
I had the same error using following system configuration
Python-2.6.6 installed as msi
mercurial-1.8.2-x86 installed as msi
IIS7
I solved this problem simply:
Python has been installed early
Uninstall Mercurial msi package
Download and install "Mercurial-1.8.2 (32-bit py2.6)" installer from mercurial website which is marked as "This is recommended for hgweb setups".
copyed content of C:\Python26\Lib\site-packages\mercurial\ to the directory used in IIS7 website setup.
Till now all is working. Hope this will help.
Whenever I have less than descriptive error messages that tell me something is going on at the system level but not what, I use Sysinternals' Procmon to tell me what's going with the registry and filesystem. It's verbose, and getting the filter to show just the process of interest takes some learning, but you can export the results to Excel and skim them for suspicious-looking results. Pay particular attention to failures, of course.
Give it a try and see what DLL is being searched for.

Categories

Resources