Error when analysing code (pylint) on Spyder - python

I use Spyder 5 (Python 3.7.9), although I also installed Python 3.9 but not with Spyder.
When I press F8 to run a Static Analysis Code, a message displays:
Traceback (most recent call last):
File "D:\obj\windows-release 37amd64_Release\msi_python\zip_amd64\runpy.py", line 193, in
_run_module_as_main
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 85, in
_run_code
File "C:\Program Files\Spyder\pkgs\pylintmain.py", line 9, in <<module> pylint.run_pylint()
File "C:\Program Files\Spyder\pkgs\pylint_init.py", line 21, in run_pylint from pylint.lint import Run as PylintRun
File "C:\Program Files\Spyder pkgs\pylint\lint_init.py", line 75, in <module> from pylint.lint.parallel import check_parallel
File "C:\Program Files\Spyder\pkgs\pylint\lint\parallel.py", line 7, in <module>
from pylint import reporters File "C:\Program Files\Spyder\pkgs\pylint\reportersinit.py", line 25, in <module>
from pylint import utils
File "C:\Program Files\Spyder\pkgs\pylint\utils_init__.py", line 45, in <module>
from pylint.utils.ast walker import ASTWalker
File "C:\Program Files\Spyder\pkgs\pylint\utils\ast_walker.py", line 6, in <module>
from astroid import nodes
File "C:\Program Files\Spyder\pkgs\astroidinit.py", line 46, in <module>
from pathlib import Path
ModuleNotFoundError: No module named 'pathlib'
Before installing Spyder 5 (I had Spyder 3), it worked, but since I've updated Spyder, it won't anymore.
Thank you!

(Spyder maintainer here) This is a bug in our Windows installer and we'll try to fix it in our next version, to be released in June.

It look like you're in fact using python2 and not python 3.7. Your default python might be python2 so you should try using python3 instead of python when launching commands, or try changing the default python for your system (if at all possible).

Related

jupyter notebook python compatibility

I am totally new to Python/Jupyter notebook.
Using Windows 11. I installed latest version python Python 3.11.1. Also latest Anaconda - conda 22.9.0.
My jupyter notebook (installed by anaconda) does not start from command line:
jupyter notebook
Traceback (most recent call last):
File "C:\apps\anaconda\Scripts\jupyter-notebook-script.py", line 6, in from notebook.notebookapp import main
File "C:\apps\anaconda\lib\site-packages\notebook\notebookapp.py", line 77, in from .services.kernels.kernelmanager import MappingKernelManager, AsyncMappingKernelManager
File "C:\apps\anaconda\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 18, in
from jupyter_client.session import Session
File "C:\apps\anaconda\lib\site-packages\jupyter_client_init_.py", line 8, in from .asynchronous import AsyncKernelClient # noqa
File "C:\apps\anaconda\lib\site-packages\jupyter_client\asynchronous_init_.py", line 1, in
from .client import AsyncKernelClient # noqa
File "C:\apps\anaconda\lib\site-packages\jupyter_client\asynchronous\client.py", line 6, in
from jupyter_client.channels import HBChannel
File "C:\apps\anaconda\lib\site-packages\jupyter_client\channels.py", line 12, in import zmq.asyncio
File "C:\apps\anaconda\lib\site-packages\zmq_init_.py", line 103, in from zmq import backend
File "C:\apps\anaconda\lib\site-packages\zmq\backend_init_.py", line 31, in raise original_error from None
File "C:\apps\anaconda\lib\site-packages\zmq\backend_init_.py", line 26, in ns = select_backend(first)
File "C:\apps\anaconda\lib\site-packages\zmq\backend\select.py", line 31, in select_backend mod = import_module(name)
File "C:\apps\anaconda\lib\importlib_init.py", line 127, in import_module return _bootstrap.gcd_import(name[level:], package, level)
File "C:\apps\anaconda\lib\site-packages\zmq\backend\cython_init.py", line 6, in
from . import (ImportError: DLL load failed while importing _device: The specified module could not be found.
Conda documentation states "Anaconda supports Python 3.7, 3.8, 3.9 and 3.10. The current default is Python 3.9."
Should I just downgrade my python to 3.9 or 3.10 (I dont care) ?? Any other work arounds?
Updates
Could open the jupyter notebook from the conda prompt. Not stated using it yet. So lets see. If python compatibility issues need to be resolved - need to figure it out.
But, cant start the anaconda-navigator. When I try start from windows start menu - does nothing. From Conda prompt: I get the flwg error on the prompt: >anaconda-navigator Traceback (most recent call last): File "C:\apps\anaconda\Scripts\anaconda-navigator-script.py", line 6, in <module> from anaconda_navigator.app.main import main File "C:\apps\anaconda\lib\site-packages\anaconda_navigator\app\main.py", line 19, in <module> from anaconda_navigator.app.start import start_app File "C:\apps\anaconda\lib\site-packages\anaconda_navigator\app\start.py", line 15, in <module> from qtpy.QtCore import QCoreApplication, QEvent, QObject, Qt # pylint: disable=no-name-in-module File "C:\apps\anaconda\lib\site-packages\qtpy\QtCore.py", line 15, in <module> from PyQt5.QtCore import * ImportError: DLL load failed while importing QtCore: The specified procedure could not be found.

I can't install any python package

When I'm trying to install any package using PyCharm terminal, I always get this error.
(venv) C:\Users\Mi\Desktop\MAIN\Coding\python>pip install PyMySQL
Traceback (most recent call last):
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\Scripts\pip-script.py",
line 11, in <module>
load_entry_point('pip==19.0.3', 'console_scripts', 'pip')()
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 489, in load_entry_point
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 2793, in load_entry_point
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 2411, in load
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 2417, in resolve
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\cli\autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\cli\main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\commands\__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\commands\completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\cli\base_command.py", line 20, in <module>
from pip._internal.download import PipSession
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\download.py", line 6, in <module>
from json import json
ImportError: cannot import name 'json' from 'json' (C:\Users\Mi\Anaconda3\lib\json\__
init__.py)
But when I use pip install the library is installed, but it still doesn't work in PyCharm.
Thanks for help! And sorry for my english.
you can try to download corresponding pacages in '.tar.gz' format on this link
manually unzip it
enter the unzipped folder
install the package through the following cmd command:
python setup.py install
here I suppose you are using windows and your python is above 3
If you are continuously encontering this problem,I suggest you alter the original download channel to a mirror.
If you installed the library through terminal and Pycharm still doesn't recognize the library, I think may be you should select the correct interpreter for the project by clicking the project interpreter at the bottom right in a Pycharm project. Look at the image in this
link. Click on the Interpreter which is named just "Python 3.x", it may work then.
["3.x" as in which version of python you are using]

Cannot import tensorflow in python3 and ImportError: This package should not be accessible on Python 3

I am trying to use tensorflow for research in my macbook. I use pip3 to install tensorflow in the system (not in virtual environment).
At first, I just want to verify tensorflow can be correctly imported via python3 in terminal. However, sometimes, I got the following problem when importing.
>>>import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/python/__init__.py", line 47, in <module>
import numpy as np
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/Library/Python/2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /Library/Python/2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace in /Library/Python/2.7/site-packages/numpy/core/multiarray.so
This error could only be solved if I ran the following code firstly before python3 execution
unset PYTHONPATH
If I didn't unset PYTHONPATH, I also found errors when checking the version of pip3 using
pip3 --version
The errors are shown as follows.
>> pip3 --version
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pip._internal import main
File "/Library/Python/2.7/site-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/Library/Python/2.7/site-packages/http/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
I thought it was so inconvenient to unset PYTHONPATH every time, so is there any solutions for this problem? I also want to import tensorflow in other text editor, such as Sublime and Pycharm, so I was really not sure what to do next.
I tried the same scenario. It is working fine for me. In the first error it seems your python installation is messed up. If you are using python3 in terminal, it should not refer to 2.7 libraries.
Also I dont think you require unset PYTHONPATH everytime. First thing is you dont need to setup PYTHONPATH. It seems the installation got issue.
You using homebrew in mac to install packages. If not I will say use homebrew and it will work as charm. As it adds dependency properly.
Thanks,
Ashish

importing pywinauto.application throws error while trying to run using python 3.5.4

I was trying to execute the following command on windows 10 machine using python 3.5.4,
from pywinauto.application import Application
Following is the error which i was receiving
Traceback (most recent call last):
File "C:/Users/bizact/Desktop/PSAV/test.py", line 1, in <module>
from pywinauto.application import Application
File "C:\Program Files\Python35\lib\site-packages\pywinauto\__init__.py", line 72, in <module>
from . import findwindows
File "C:\Program Files\Python35\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Program Files\Python35\lib\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
File "C:\Program Files\Python35\lib\site-packages\pywinauto\controls\uiawrapper.py", line 46, in <module>
from ..uia_defines import IUIA
File "C:\Program Files\Python35\lib\site-packages\pywinauto\uia_defines.py", line 35, in <module>
import comtypes.client
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\__init__.py", line 33, in <module>
gen_dir = _find_gen_dir()
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\_code_cache.py", line 71, in _find_gen_dir
result = os.path.abspath(gen_path[-1])
IndexError: list index out of range
Is there a way i can fix this ?
Try running the script with administrative privileges. Just by looking at the traceback it looks like some cached files that pywinauto import tried to write but later on it wasn't found, and generally the script can't write the file due to permissions. If the above don't work, try installing python somewhere else (C:/Python with full privileges in order to isolate the issue)
This is comtypes issue. It will be fixed soon (EDIT: fixed in comtypes==1.1.7). You can downgrade to one of previous versions: pip install comtypes==1.1.2. Or run script as Administrator as Rodolfo suggested (disabling UAC may not help, need to say explicitly to "run as Administrator" by popup menu).

why is my spyder IDE no longer opening

I just closed my spyder IDE on win7 64bit 64bit python2.7 after a long session.
during that last session, I had also installed a couple of new libraries via conda install. maybe that threw things off?
now when I try to start spyder again, the spyder splash screen appears briefly but then spyder doesn't open. if I try to start spyder from the command line, I get the following error:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\jlarsch>conda install spyder
Warning: could not import binstar_client (A 0.7-series setuptools cannot be inst
alled with distribute. Found one at c:\users\jlarsch\appdata\local\continuum\ana
conda\lib\site-packages\setuptools-20.7.0-py2.7.egg)Fetching package metadata: .
...
Solving package specifications: .........
# All requested packages already installed.
# packages in environment at C:\Users\jlarsch\AppData\Local\Continuum\Anaconda:
#
spyder 2.3.9 py27_0
C:\Users\jlarsch>spyder
Traceback (most recent call last):
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\Scripts\spyder-script.
py", line 2, in <module>
start_app.main()
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\start_app.py", line 114, in main
from spyderlib import spyder
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\spyder.py", line 137, in <module>
from spyderlib.ipythonconfig import IPYTHON_QT_INSTALLED
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\ipythonconfig.py", line 24, in <module>
required_version=IPYTHON_REQVER)
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\dependencies.py", line 70, in add
installed_version)]
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\dependencies.py", line 32, in __init__
self.installed_version = programs.get_module_version(modname)
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\utils\programs.py", line 238, in get_module_version
mod = __import__(module_name)
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\IPyt
hon\__init__.py", line 48, in <module>
from .terminal.embed import embed
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\IPyt
hon\terminal\embed.py", line 16, in <module>
from IPython.core.interactiveshell import DummyMod
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\IPyt
hon\core\interactiveshell.py", line 31, in <module>
from pickleshare import PickleShareDB
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\pick
leshare.py", line 41, in <module>
from path import path as Path
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\path
.py", line 126, in <module>
except pkg_resources.DistributionNotFound:
NameError: name 'pkg_resources' is not defined
seems related to this issue but I don't understand how I might be able to fix this on windows?
try this download setuptools from here and install.

Categories

Resources