hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.58k stars 291 forks source link

can't run autopep8 #137

Closed qiweiye closed 10 years ago

qiweiye commented 10 years ago

said that the pep8 version is not right. but i already update the pep8 to 1.5.6.

qwy-macbp:~ qiweiye$ autopep8 --version Traceback (most recent call last): File "/usr/local/bin/autopep8", line 5, in from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in working_set.require(requires) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require needed = self.resolve(parse_requirements(requirements)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: pep8>=1.5.5

qwy-macbp:~ qiweiye$ pep8 --version 1.5.6 qwy-macbp:~ qiweiye$ pip install --upgrade autopep8 Requirement already up-to-date: autopep8 in /Library/Python/2.7/site-packages Requirement already up-to-date: pep8>=1.5.5 in /Library/Python/2.7/site-packages (from autopep8) Cleaning up...

qwy-macbp:~ qiweiye$ pip install --upgrade pep8 Requirement already up-to-date: pep8 in /Library/Python/2.7/site-packages Cleaning up...

myint commented 10 years ago

Try uninstalling both first:

$ pip uninstall autopep8 pep8

$ pip install --upgrade autopep8
qiweiye commented 10 years ago

still not work.

qwy-macbp:~ qiweiye$ sudo pip uninstall autopep8 pep8 Uninstalling autopep8: /Library/Python/2.7/site-packages/autopep8-1.0.1-py2.7.egg-info /Library/Python/2.7/site-packages/autopep8.py /Library/Python/2.7/site-packages/autopep8.pyc /usr/local/bin/autopep8 Proceed (y/n)? Y Successfully uninstalled autopep8 Uninstalling pep8: /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/DESCRIPTION.rst /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/METADATA /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/RECORD /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/WHEEL /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/entry_points.txt /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/namespace_packages.txt /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/pydist.json /Library/Python/2.7/site-packages/pep8-1.5.6.dist-info/top_level.txt /Library/Python/2.7/site-packages/pep8.py /Library/Python/2.7/site-packages/pep8.pyc /usr/local/bin/pep8 Proceed (y/n)? Y
Successfully uninstalled pep8 qwy-macbp:~ qiweiye$ sudo pip install --upgrade autopep8 Downloading/unpacking autopep8 Downloading autopep8-1.0.1.tar.gz (103kB): 103kB downloaded Running setup.py (path:/private/tmp/pip_build_root/autopep8/setup.py) egg_info for package autopep8

warning: no files found matching 'test/example'
warning: no previously-included files matching '*.py' found under directory 'test/suite'
warning: no previously-included files matching '*.py' found under directory 'test/suite/out'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching 'CONTRIBUTING.rst'
warning: no previously-included files found matching 'Makefile'
warning: no previously-included files found matching 'coveralls.bash'
warning: no previously-included files found matching 'hooks'
warning: no previously-included files found matching 'hooks/pre-push'
warning: no previously-included files found matching 'install_hooks.bash'
warning: no previously-included files found matching 'test/.gitignore'
warning: no previously-included files found matching 'test/acid.py'
warning: no previously-included files found matching 'test/acid_github.py'
warning: no previously-included files found matching 'test/acid_pypi.py'
warning: no previously-included files found matching 'test/suite'
warning: no previously-included files found matching 'test/suite/out'
warning: no previously-included files found matching 'test/vim_autopep8.py'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'update_readme.py'

Downloading/unpacking pep8>=1.5.5 (from autopep8) Downloading pep8-1.5.6-py2.py3-none-any.whl Installing collected packages: autopep8, pep8 Running setup.py install for autopep8

warning: no files found matching 'test/example'
warning: no previously-included files matching '*.py' found under directory 'test/suite'
warning: no previously-included files matching '*.py' found under directory 'test/suite/out'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching 'CONTRIBUTING.rst'
warning: no previously-included files found matching 'Makefile'
warning: no previously-included files found matching 'coveralls.bash'
warning: no previously-included files found matching 'hooks'
warning: no previously-included files found matching 'hooks/pre-push'
warning: no previously-included files found matching 'install_hooks.bash'
warning: no previously-included files found matching 'test/.gitignore'
warning: no previously-included files found matching 'test/acid.py'
warning: no previously-included files found matching 'test/acid_github.py'
warning: no previously-included files found matching 'test/acid_pypi.py'
warning: no previously-included files found matching 'test/suite'
warning: no previously-included files found matching 'test/suite/out'
warning: no previously-included files found matching 'test/vim_autopep8.py'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'update_readme.py'
Installing autopep8 script to /usr/local/bin

Successfully installed autopep8 pep8 Cleaning up... qwy-macbp:~ qiweiye$ auto autoautotest autodiskmount automator automount autopep8 autotest
qwy-macbp:~ qiweiye$ autopep8 /tmp/1.py Traceback (most recent call last): File "/usr/local/bin/autopep8", line 5, in from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in working_set.require(requires) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require needed = self.resolve(parse_requirements(requirements)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: pep8>=1.5.5 qwy-macbp:~ qiweiye$

myint commented 10 years ago

Maybe it is a permission error. I've never used pip under sudo before. Does the following work?

$ sudo autopep8

One last thing you could try is hack the requires.txt to remove the pep8 dependency.

$ rm /Library/Python/2.7/site-packages/autopep8-1.0.1-py2.7.egg-info/requires.txt
$ touch /Library/Python/2.7/site-packages/autopep8-1.0.1-py2.7.egg-info/requires.txt

$ autopep8
myint commented 10 years ago

It looks like I can reproduce this on Travis when installing using sudo. I perhaps could have done the same on my own machine, but I don't like to clutter the system directories.

https://travis-ci.org/myint-test-org/test-osx/builds/23866573

It is kind of interesting that this has never been reported before.

myint commented 10 years ago

I found the workaround. Try uninstalling the autopep8 and pep8 again. Then install using the following command.

$ sudo pip install --no-use-wheel autopep8

https://travis-ci.org/myint-test-org/test-osx/jobs/23867467

myint commented 10 years ago

See 9d29b43bc31dde58b80ea6b5adf585d7087b1afe.

myint commented 10 years ago

This is related to currently unresolved issue pypa/pip#1480.