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!
Related
I would like to install this library with pip: ikpy library. However pip gives the error below:
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/pip-build-oYTjdr/ikpy/setup.py'
What I understand from the error, pip cannot find setup.py, becuase library has setup.cfg instead. I tried to upgrade pip and got a different error.
$ pip install --upgrade pip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-KCnfi9/pip/setup.py", line 7
def read(rel_path: str) -> str:
^
SyntaxError: invalid syntax
I also tried pip3:
$ pip3 install ikpy
ModuleNotFoundError: 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 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, 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'
What should I do?
Python 3.7.10, python3-pip: (8.1.1-2ubuntu0.6).
Note:
I solved with these commands, now it can be installed with pip3:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
pip3 install --upgrade setuptools
(this message was created before the question was updated with pip3)
It's likely that the pip command you use is for Python 2. Can you try with pip3 instead?
From ikpy library:
Starting with IKPy v3.1, only Python 3 is supported.
For versions before v3.1, the library can work with both versions of Python (2.7 and 3.x).
You can download the latest version compatible with python 2 here:
https://github.com/Phylliade/ikpy/releases/tag/v3.0.1
note: using python 2.7 is not recommended because support for Python version 2.7 will end on January 1, 2020
Upgrade Your Pip
pip install --upgrade pip
then install ikpy Now it's should up and running ;-)
pip install ikpy
Installed and Checked now on: Ubuntu 20.04, Pip 21.3, Python 3.8.10
I'm running Ubuntu focal fossa 20.04, and I just tried installing python. It worked, however, I can't use pip. I tried looking up answers but that didn't fix it. Here is the problem.
Terminal
Input
user#hostname:~$ python3 get-pip.py
Output
python3: can't open file '/home/user/get-pip.py': [Errno 2] No such file or directory
(Edit)Followed first answer;
Input
user#hostname:~/Downloads$ python3 get-pip.py
Output
Traceback (most recent call last):
File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 568, in _get_data
File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/Downloads/get-pip.py", line 24184, in <module>
main()
File "/home/user/Downloads/get-pip.py", line 139, in main
bootstrap(tmpdir=tmpdir)
File "/home/user/Downloads/get-pip.py", line 115, in bootstrap
monkeypatch_for_cert(tmpdir)
File "/home/user/Downloads/get-pip.py", line 96, in monkeypatch_for_cert
from pip._internal.commands.install import InstallCommand
File "<frozen zipimport>", line 241, in load_module
File "<frozen zipimport>", line 709, in _get_module_code
File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
Update, installed zlib, had to download a different get-pip.py, and it worked!
I've never seen get-pip.py, but after a quick research, it looks like this is a manual way of installing pip.
However you need to actually download the script. It's not something that's bundled with Python.
To manually install pip, securely 1 download get-pip.py by following this link: get-pip.py. Alternatively, use curl: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Please review: https://pip.pypa.io/en/stable/installing/
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 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!
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