I am a complete newbie to Python.
I have downloaded and installed Anaconda 3.5.2 on Windows 7, then Eclipse Photon. Installed the PyDev Plugin.
I was able to run a few simple test programs in Eclipse.
Suddenly, without installing anything I get
Error processing line 1 of C:\Anaconda3\lib\site-packages\matplotlib-2.2.2-py3.6-nspkg.pth:
Failed to import the site module
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "C:\Anaconda3\lib\types.py", line 171, in <module>
import functools as _functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 541, in <module>
main()
File "C:\Anaconda3\lib\site.py", line 523, in main
known_paths = addsitepackages(known_paths)
File "C:\Anaconda3\lib\site.py", line 320, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Anaconda3\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Anaconda3\lib\site.py", line 178, in addpackage
import traceback
File "C:\Anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Anaconda3\lib\linecache.py", line 8, in <module>
import functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
even with a "Hello World" which ran before
Any ideas what could cause this?
I have found the reason:
I have added a "PyDev Package" named "collections" in the IDE. This collided with something ....
You can try a few things. Have you tried updating the package in conda? It is possible it is not up to date. Also, with Eclipse (and with most IDEs) if things that were working a moment break without any changes it is a sign you should quit the program, give it a moment to settle, and try reopening and rerunning your code. Sometimes it is the tool's fault!
Related
UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server\server.py", line 20, in
from notebook.notebookapp import aliases, flags, NotebookApp as ServerApp
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\notebook\notebookapp.py", line 51, in
from zmq.eventloop import ioloop
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq_init_.py", line 50, in
from zmq import backend
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend_init_.py", line 40, in
reraise(*exc_info)
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend_init_.py", line 27, in
ns = select_backend(first)
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = import(name, fromlist=public_api)
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend\cython_init.py", line 6, in
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\user\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\Lib\site-packages\jupyter-lab.exe_main.py", line 4, in
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab\labapp.py", line 14, in
from jupyterlab_server import slugify, WORKSPACE_EXTENSION
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server_init.py", line 4, in
from .app import LabServerApp
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server\app.py", line 9, in
from .server import ServerApp
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server\server.py", line 29, in
from jupyter_server.extensions import ( # noqa
ModuleNotFoundError: No module named 'jupyter_server.extensions
It feels like you have not installed some required modules e.g. jupyter_server.extensions and or setuptools. I guess you need to pip install them. Worth checking also whether you have more than one versions of python installed as this may cause issues some times.
I use Ubuntu 18.04. By mistake, I changed argparse.py file in usr/lib/python3.6. I couldn't fix it and I thought to remove it, so I could reinstall. Now I can't reinstall, whenever I try "pip install argparse" I get an error like this:
Defaulting to user installation because normal site-packages is not writeable
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 279, in run
session = self.get_default_session(options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 74, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 91, in _build_session
index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 241, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 129, in user_agent from pip._vendor import distro
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py", line 37, in <module>
import argparse ModuleNotFoundError: No module named 'argparse'
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 105, in main return self._main(args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 224, in _main self.handle_pip_version_check(options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 146, in handle_pip_version_check timeout=min(5, options.timeout)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 91, in _build_session index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 241, in __init__self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 129, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py", line 37, in <module>
import argparse
ModuleNotFoundError: No module named 'argparse'
Could you please help me to fix this?
argparse is part of the standard library, not a third-party module. The standard library is not managed via pip (that is both its blessing and its bane).
So you have to fix or reinstall python itself.
argparse is (since Python 3.2) part of the standard library. Just get the file from the official github (I'm assuming cpython, adapt the version as necessary by selecting the correct branch, the link is for python 3.8) and put it back where the one you deleted was
I installed phenix (phenix-installer-1.17.1-3660-intel-linux-2.6-x86_64-centos6) on my CentOS 7 system according the installation guide (https://www.phenix-online.org/documentation/install-setup-run.html). The original python version (/usr/bin/python) in my system is 2.7.5, but I installed anaconda3, so the output of "which python" command is "~/software/build/anaconda3/bin/python".
I tried to study the p9-sad tutorial and run the command "phenix.run_example p9-sad", but it gave the following error information:
Examples to be run: p9-sad
Running PHENIX example: p9-sad Fri Jan 17 15:04:44 CST 2020
Working directory: /home/sunyp/Documents/tutorial/PHENIX/p9-sad
Starting run now ... please wait a moment
Error processing line 1 of /home/sunyp/software/build/anaconda3/lib/python3.7/site-packages/google_auth-1.7.1-py3.6-nspkg.pth:
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/home/sunyp/software/build/anaconda3/lib/python3.7/importlib/util.py", line 14, in <module>
from contextlib import contextmanager
File "/home/sunyp/software/build/anaconda3/lib/python3.7/contextlib.py", line 5, in <module>
from collections import deque
File "/home/sunyp/software/build/anaconda3/lib/python3.7/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/lib/python2.7/site-packages/reprlib/__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.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/build/../conda_base/lib/python2.7/site-packages/site.py", line 73, in <module>
__boot()
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/build/../conda_base/lib/python2.7/site-packages/site.py", line 22, in __boot
loader.load_module('site')
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 570, in <module>
main()
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 557, in main
known_paths = addsitepackages(known_paths)
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "/home/sunyp/software/build/anaconda3/lib/python3.7/site.py", line 178, in addpackage
import traceback
File "/home/sunyp/software/build/anaconda3/lib/python3.7/traceback.py", line 3, in <module>
import collections
File "/home/sunyp/software/build/anaconda3/lib/python3.7/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/lib/python2.7/site-packages/reprlib/__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.
Does it mean that phenix requires python2 rather python3, but there is python3 in my system, so the error came out? And how to solve the problem? Thank you in advance.
Regards,
Yeping Sun
Solely based on /home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/lib/python2.7/site-packages/reprlib/__init__.py Phenix contains a Python 2.7 environment.
You could maybe try running your code with /home/sunyp/software/Phenix/phenix-1.17.1-install/phenix-1.17.1-3660/conda_base/bin/python or something to use that Python interpreter, but it's hard to tell since Phenix source is not openly available.
Your environment probably contains path to python2.7.5
Check your PYTHONPATH
This doesn't work with Python 3 for obvious reasons. To remove it:
unset PYTHONPATH
I have poured about 6 hours into this issue now and I'm getting farther and farther. Here's what happened.
I am using a shared Linux machine that has both Python 2.7 and Python 3.5 and I don't have admin privileges. I was using Python 3.5 and I wanted to use the package seaborn and I found out the specific labeling feature I wanted was only available in a newer version. So no problem "pip3 install seaborn --upgrade".
Everything was happening so fast but something went wrong and by the suggestion of the internet, I ended up upgrading a few other packages like matplotlib, setuptools, and eventually pip itself.
Here's where it really went wrong. Pip just broke. This happens when I run pip3 --version:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13, in <module>
from pip.exceptions import InstallationError, CommandError, PipError
File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6, in <module>
from pip._vendor.six import iteritems
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in <module>
vendored("pkg_resources")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2927, in <module>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2913, in _call_aside
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 956, in subscribe
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in <lambda>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2515, in activate
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2097, in declare_namespace
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2047, in _handle_ns
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'
The first line in the call stack is "from pip import main" so I tried running pip --version instead of pip3 and now I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
This error is all over the internet as a bug in pip itself but all every solution involves something that I don't have permission to do. I tried to uninstall and reinstall an older version of pip using "python -m pip ..." but this did not help with the pip3 error, which prompted the same error a few lines later. And I can't use this shortcut with pip3 (python3 -m pip...) because this error occurs anyway.
Worst part is that my original program is now completely dead. I can't even import seaborn at all without crashing.
Traceback (most recent call last):
File "/u/hailey/.local/lib/python3.5/site-packages/matplotlib/__init__.py", line 861, in __setitem__
cval = self.validate[key](val)
KeyError: 'axes.color_cycle'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "nn.py", line 9, in <module>
import seaborn as sns
File "/usr/lib/python3/dist-packages/seaborn/__init__.py", line 13, in <module>
set()
File "/usr/lib/python3/dist-packages/seaborn/rcmod.py", line 98, in set
set_palette(palette, color_codes=color_codes)
File "/usr/lib/python3/dist-packages/seaborn/rcmod.py", line 491, in set_palette
mpl.rcParams["axes.color_cycle"] = list(colors)
File "/u/hailey/.local/lib/python3.5/site-packages/matplotlib/__init__.py", line 868, in __setitem__
'list of valid parameters.' % (key,))
KeyError: 'axes.color_cycle is not a valid rc parameter. See rcParams.keys() for a list of valid parameters.'
At this point, I decided everything would be easier if I just downloaded my own clean version of Python in a local directory where I have privileges. So I downloaded and set up a new version of Python 3.6 in a local directory. Then I ran my original program with this and I was told I had no module named 'numpy'. Reasonable. Let's try to install numpy.
Obtaining file:///u/hailey/python36/Python-3.6.0
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/u/hailey/python36/Python-3.6.0/setup.py", line 4, in <module>
import sys, os, importlib.machinery, re, optparse
ImportError: No module named machinery
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /u/hailey/python36/Python-3.6.0/
Now I'm led to a page that recommends running "setup.py install", which sounds simple enough. But nope.
bash: /u/hailey/python36/Python-3.6.0/setup.py: Permission denied
Now I'm giving up because evidently I know nothing about Python. I would really appreciate some help with this. At this point, even just recovering the state I had yesterday would be fine as I can live without the extra label on my seaborn graph. Thanks everyone!
I wrote a program using PyQt4.QtGui and QtCore,I packaged it into exe,and it works good on my computer,but it can't run on others' computer
The error is this:
cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in <module>
File "baidu.py", line 6, in <module>
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1607, in _handle_fromlist
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_with_frames_removed
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1558, in _find_and_load
File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1525, in _find_and_load_unlocked
File "ExtensionLoader_PyQt4_QtGui.py", line 11, in <module>
ImportError: DLL load failed: 找不到指定的模块。
The packaged files are:
├─_bz2.pyd
├─_hashlib.pyd
├─_socket.pyd
├─_ssl.pyd
├─baidu.exe
├─icudt49.dll
├─icuin49.dll
├─icuuc49.dll
├─LIBEAY32.dll
├─libGLESv2.dll
├─lxml.etree.pyd
├─PyQt4.QtCore.pyd
├─PyQt4.QtGui.pyd
├─PyQt4.QtNetwork.pyd
├─python33.dll
├─Qt5Core.dll
├─Qt5Gui.dll
├─Qt5Network.dll
├─Qt5PrintSupport.dll
├─Qt5Widgets.dll
├─sip.pyd
├─SSLEAY32.dll
└─unicodedata.pyd
I just used "cxfreeze baidu.py --base-name=Win32GUI --target-dir d:\123" to package it.
I wonder if I missed some arguments when using cxfreeze result in this problem,and how to package it to exe.Thank you
d3dcompiler_43.dll is needed to run pyqt