I installed flake8 using the following command.
pip3 install flake8
Executing flake8 from terminal gives the following error.
Traceback (most recent call last):
File "/home/bilesh/.local/bin/flake8", line 11, in <module>
sys.exit(main())
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/cli.py", line 18, in main
app.run(argv)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 394, in run
self._run(argv)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 381, in _run
self.initialize(argv)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 365, in initialize
self.register_plugin_options()
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/main/application.py", line 206, in register_plugin_options
self.check_plugins.register_options(self.option_manager)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 496, in register_options
list(self.manager.map(register_and_enable))
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 302, in map
yield func(self.plugins[name], *args, **kwargs)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 492, in register_and_enable
call_register_options(plugin)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 404, in generated_function
return method(optmanager, *args, **kwargs)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 221, in register_options
add_options(optmanager)
File "/home/bilesh/.local/lib/python3.6/site-packages/flake8/_pyflakes.py", line 79, in add_options
parser.config_options.extend(['builtins', 'doctests',
AttributeError: 'OptionManager' object has no attribute 'config_options'
Found the following bug from 2016 but it seems to have been fixed.
https://github.com/PyCQA/flake8-import-order/issues/79
Not sure if I'm doing anything wrong here. Any help will be appreciated.
$ pip3 freeze | grep flake8
flake8==3.7.7
flake8-docstrings==1.3.0
flake8-polyfill==1.0.2
So, as per the comment posted by phd on this question, I did the following things.
Uninstall flake8: pip3 uninstall flake8
Clean directories: sudo rm -R /path/to/directory/flake8
Reinstall flake8: pip3 install flake8
And it worked :)
Related
Suggestions please, thanks :)
pip list --outdated --format=freeze
Gives the following error:
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 175, in run
packages = self.get_outdated(packages, options)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 184, in get_outdated
return [
File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 184, in <listcomp>
return [
File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 237, in iter_packages_latest_infos
for dist in map_multithread(latest_info, packages):
File "/usr/lib/python3.9/multiprocessing/pool.py", line 870, in next
raise value
File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/list.py", line 214, in latest_info
all_candidates = finder.find_all_candidates(dist.key)
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 825, in find_all_candidates
package_links = self.process_project_url(
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 793, in process_project_url
page_links = list(parse_links(html_page))
File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 324, in wrapper_wrapper
return list(fn(page))
File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 335, in parse_links
document = html5lib.parse(
File "/usr/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl/html5lib/html5parser.py", line 44, in parse
tb = treebuilders.getTreeBuilder(treebuilder)
File "/usr/share/python-wheels/html5lib-1.1-py2.py3-none-any.whl/html5lib/treebuilders/__init__.py", line 85, in getTreeBuilder
return etree.getETreeModule(implementation, **kwargs).TreeBuilder
AttributeError: module 'html5lib.treebuilders.etree' has no attribute 'getETreeModule'
I solved this problem updating pip, i updated from pip 20.3.4 to 21.3
so just type:
pip install pip -U
Seems like there is some bug in pip itself.
I've done some analysis of this bug in in the Debian bugtracker.
It appears to be a race-condition triggered by the way Debian was packaging pip until recently. Dependencies were zipimported from wheels instead of vendored in the source tree, as upstream does.
This should already be resolved in Debian >= 12 (bookworm) and Ubuntu >= 22.04 (jammy).
An updated for pip in Debian 11 (bullseye) is in progress.
Not a fix, but a solution of sorts:
I 'fixed' this by updating every package.
for f in `pip list | tail -n +3 | cut -d' ' -f1`; do
pip install --update "$f";
done
I found OP's problem while logged-in as root and immediately after upgrading to Debian 11; dunno if that's significant.
I think i have messed up some python files when installing some packages in a requirement.txt file
now i get these errors when trying to install or uninstall anything:
for example when trying to uninstall matplotlib without sudo using pip3 uninstall matplotlib (even tho i never had to use sudo to uninstall anything before) :
Found existing installation: matplotlib 3.3.1
Uninstalling matplotlib-3.3.1:
Would remove:
/usr/local/lib/python3.8/dist-packages/matplotlib-3.3.1-py3.8-linux-x86_64.egg
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/shutil.py", line 788, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/matplotlib-3.3.1-py3.8-linux-x86_64.egg' -> '/tmp/pip-uninstall-nw393b36'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/commands/uninstall.py", line 89, in run
uninstall_pathset = req.uninstall(
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 686, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py", line 394, in remove
moved.stash(path)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py", line 283, in stash
renames(path, new_path)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 352, in renames
shutil.move(old, new)
File "/usr/lib/python3.8/shutil.py", line 800, in move
rmtree(src)
File "/usr/lib/python3.8/shutil.py", line 715, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib/python3.8/shutil.py", line 672, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/usr/lib/python3.8/shutil.py", line 670, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'pylab.py'
When trying with sudo :
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/local/lib/python3.8/dist-packages/pip/commands/uninstall.py", line 46, in run
with self._build_session(options) as session:
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 33, in <module>
sys.exit(load_entry_point('pip==20.3.dev0', 'console_scripts', 'pip3')())
File "/usr/local/lib/python3.8/dist-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 242, in main
with self._build_session(
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
How can i fix this? i am using ubuntu 20.04 and i heard uninstalling python3.8 is a big no no since many system files use it, so what should i do?
tried many suggestion on similar questions like this and it didn't work:
How to fix "module 'platform' has no attribute 'linux_distribution'" when installing new packages with Python3.8?
Python 3.8 removed some stuff. I solved my problems with pip (specifically pip install) by installing pip with curl
What worked for me was:
cd ~/Downloads
Downloading get-pip.py
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then running it with python 3.8:
python3.8 get-pip.py
Solved it for me.
If found some hits on stackoverflow where people have issues using ete3 tools when PyQT4 is not installed, and this (used to) also apply for me. However, I've now tried to reinstall a piece of software and it keeps complaining about 'Module' has no attritube 'Treestyle'.
To test whether PyQT was installed, I ran this python script:
from PyQt4.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)
Which prints:
('PyQt version:', '4.12.1')
I get this (common) error:
Traceback (most recent call last):
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1820, in <module>
sys.exit(main())
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1793, in main
args.start(args)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 408, in start_evo_sim
result = init_and_simulate(simu, intermediate_load_file, _options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 117, in wrapper
raise ex_type(message)
AttributeError: 'module' object has no attribute 'TreeStyle' (in subprocess)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 91, in process_func
ret = func(*args, **kwargs)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 295, in init_and_simulate
sim = sim_mod.create_simulation(**options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1940, in create_simulation
sim = ODE_simulation(params_dict)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1342, in __init__
super(ODE_simulation, self).__init__(params)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 86, in __init__
self.init_graphs()
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 795, in init_graphs
show=show, clean=clean, create=create)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1188, in __init__
self.init_phylo_tree_graph(clean=clean)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1219, in init_phylo_tree_graph
show=show, attribute_dict=self.attribute_mapper, create=clean, **kwargs)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 985, in __init__
self.init_tree_style_dict() # NOTE: unordered ok
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1110, in init_tree_style_dict
branch_vertical_margin=branch_vertical_margin)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1083, in make_tree_style
ts = ete3.TreeStyle()
Note: this time arround I am trying to install it on Ubuntu for Windows, but up till now almost everything that ran on Linux ran on this one too. It might be relevent though.
Any ideas?
PS To reproduce the problem, follow the following steps:
$ sudo apt-get install python-qt4
$ virtualenv ~/mypy --system-site-packages
$ source ~/mypy/bin/activate
$ (mypy) > pip install VirtualMicrobes
$ (mypy) > virtualmicrobes evo --name TestMicrobes >> error
PPS User eyllanesc confirmed this is an 'Ubuntu for Windows' problem. I'm still trying to fix it though, if anyone can help me figure out how to link the pyqt4 packages correctly to my virtualenv that would be great. I've tried linken the native one with ln -s but I'm not getting any further
I had similar issues. The problem might be that you don't have all the depencies installed and ete3 is not telling you all of them.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
Run it and it will tell you which dependencies are missing. Note that you might need to run it multiple times before you install them all!
I am having some trouble deploying my elastic beanstalk app from a bitbucket pipeline. This same code had been working without issue, so my best guess is some kind of dependency issue.
(awsebcli version 3.14.1)
The image for the pipeline is python:3.5.2
and here's the failing step:
- step:
name: Test Deploy
deployment: test
caches:
- pip
script:
- pip install awsebcli --upgrade
- eb init myAppName -r us-east-1 -p Python # This line started failing :'(
- eb deploy myAppName-dev-1
and the error output:
eb init myAppName -r us-east-1 -p Python
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 570, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 888, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 779, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (PyYAML 4.1 (/usr/local/lib/python3.5/site-packages), Requirement.parse('PyYAML<4,>=3.10'), {'docker-compose'})
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/eb", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3095, in <module>
#_call_aside
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3079, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3108, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 572, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 585, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 779, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (PyYAML 4.1 (/usr/local/lib/python3.5/site-packages), Requirement.parse('PyYAML<4,>=3.10'), {'docker-compose'})
So if I'm reading this right, I have PyYAML 4.1 when I need something less than 4.
I changed the pip install line to explicitly use an older version of PyYAML and that seems to have worked...
Changed
pip install awsebcli --upgrade
To
pip install pyYAML==3.12 awsebcli --upgrade
new to coding and I think I've searched thoroughly for answers to this question, but the suggested solutions haven't been working for me. Apologies if this is a duplicate, though!
I'm trying to set up my computer according to these instructions, currently trying to get virtualenv up and running. However, pip doesn't seem to be working properly. I was able to use python -m pip as a workaround and installed virtualenv using: python -m pip install virtualenv
But the same workaround doesn't seem to work with virtualenvwrapper: python -m pip install virtualenvwrapper gives me this error:
Exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/install.py", line 324, in run
requirement_set.prepare_files(finder)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/Library/Python/2.7/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
If I try running anything directly with a pip command, such as pip install virtualenvwrapper, I get this error:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
I have a mac running Sierra (10.12.4). Python version 2.7.6. Pip 9.0.1
Thoughts? Thank you!