AttributeError: '_NamespacePath' object has no attribute 'sort' on Read the docs - read-the-docs

Pretty sure this isn't a dupe.
my read docs build fails here:
Collecting sphinxcontrib-inlinesyntaxhighlight==0.2 (from -r /home/docs/checkouts/readthedocs.org/user_builds/zproc/checkouts/latest/requirements.txt (line 33))
Using cached https://files.pythonhosted.org/packages/5c/8b/17998fe9ebbec7e176f344648a86094d7b358e63d8f4593ae3dfbb9bb560/sphinxcontrib-inlinesyntaxhighlight-0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, filterfalse, map
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3017, in <module>
#_call_aside
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside
f(*args, **kwargs)
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3045, in _initialize_master_working_set
dist.activate(replace=False)
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2577, in activate
declare_namespace(pkg)
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2151, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2091, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2120, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wlv3e5i4/sphinxcontrib-inlinesyntaxhighlight/
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Looks like it is failing to install sphinxcontrib-inlinesyntaxhighlight, which installs just fine in my local machine.
A simple search seems to say that it can be fixed using pip install --upgrade pip setuptools, but I don't know how to do that on read the docs.
Here is the requirements.txt i supply to read the docs
alabaster==0.7.11
Babel==2.6.0
backcall==0.1.0
certifi==2018.4.16
chardet==3.0.4
decorator==4.3.0
docutils==0.14
idna==2.7
imagesize==1.0.0
ipython==6.4.0
ipython-genutils==0.2.0
jedi==0.12.1
Jinja2==2.10
MarkupSafe==1.0
packaging==17.1
parso==0.3.0
pexpect==4.6.0
pickleshare==0.7.4
pkginfo==1.4.2
prompt-toolkit==1.0.15
psutil==5.4.6
ptyprocess==0.6.0
Pygments==2.2.0
pyparsing==2.2.0
pytz==2018.5
pyzmq==17.0.0
requests==2.19.1
requests-toolbelt==0.8.0
simplegeneric==0.8.1
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.7.5
sphinxcontrib-inlinesyntaxhighlight==0.2
sphinxcontrib-websupport==1.1.0
tblib==1.3.2
tinydb==3.9.0.post1
tqdm==4.23.4
traitlets==4.3.2
twine==1.11.0
urllib3==1.23
wcwidth==0.1.7

As suggested here. and quoting the same -
The _path_ attribute should always be treated as an interable, not a list (the Python docs describe _path_ as an iterable). The line in pkg_resources/_init_.py that reads:
orig_path.sort(key=position_in_sys_path)
Should be:
orig_path = sorted(orig_path, key=position_in_sys_path)
As a general rule (if practical), in-place sorting should not be used.
PS -
I tried upgrading pip and setuptools but it didn't work for me.
pip install -U pip
pip install -U setuptools

Related

cant install pygame in pycharm

First of all, I'm new to programming. So,forgive me for my mistakes. I've installed pygame in python IDLE. But when I try to install it in pycharm, this happens:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>pip install pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"?[Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>py -m pip install -U pygame --user
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\downloa
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ARMAN\AppData\Local\T
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>
I get an error. I've updated everything. Found a similar problem here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000435070-Command-python-setup-py-egg-info-failed-with-error-code-1-whatever-package-I-try-to-install-.
But I can't understand the solution. So, please kindly help me.
This isn't my answer, but an answer from here:
Pygame docs recommends that you use Python version 3.6.1 or greater,
so I would suggest you to use the most recent non-beta version. Also,
some pygame wheels are not available to this version yet.
After the python installation make sure its added to your PATH
variable and try to install Pygame using this command given that you
are on windows:
py -m pip install -U pygame --user
If you get a PermissionError then
run the command prompt as administrator.
I hope this helps.

MySQL connector fails after switching from Python 2.7.X to 3.X

I installed the following mysql connector via pip:
pip install --allow-external mysql-connector-python mysql-connector-python
In my code I simply do a import mysql.connector as Connector and everything works fine. However, I used to use Python 2.7.X and now want to switch to Python 3.X (currently 3.5).
When I run my stuff under 2.7.X everything works fine. However, starting the same script with python 3.5 I get the following error message:
Traceback (most recent call last):
File "SWCrawler3.py", line 3, in <module>
import Configuration as cfg
File "/Users/Tom/SW/SWCrawler/SWCrawler/Configuration.py", line 4, in <module>
from database.MySQLConnection import MySQLConnection as MySQLConn
File "/Users/Tom/SW/SWCrawler/SWCrawler/database/MySQLConnection.py", line 6, in <module>
import mysql.connector as Connector
File "../mysql/connector/__init__.py", line 33, in <module>
from mysql.connector.connection import MySQLConnection
File "../mysql/connector/connection.py", line 128
except Exception, err:
^
SyntaxError: invalid syntax
Please note, that I wrote a wrapper file that I call MySQLConnection.
I had to intall the python3 packages of mysql-connector-python.
On my Mac I did the following:
brew install python3
pip3 install --allow-external mysql-connector-python mysql-connector-python
After that is worked. So use pip3.
On Windows with Python 3.5, I did something very close to toom's answer, that is :
pip3.5 install --allow-external mysql-connector-python mysql-connector-python

Error installing NLTK in Python 3.4

I'm transitioning to python 3.4 and trying to install NLTK.
Pyyaml and numpy are installed, setuptools and pip as well - all in the newest version- Win 7 64bit.
However, NLTK puzzles me with an error no matter how I try to install it. Here is the cmd-output of my last try. Btw, haven't changed the files in any way ;)
Does anyone know what I could do to get NLTK up and running?
C:\Python34\Scripts\nltk-3.0a4>python setup.py install
running install
Traceback (most recent call last):
File "setup.py", line 81, in <module>
zip_safe=True, # since normal files will be present too?
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 65, i
n run
self.do_egg_install()
File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 101,
in do_egg_install
cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
File "C:\Python34\lib\distutils\cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "C:\Python34\lib\site-packages\setuptools\command\easy_install.py", line
304, in finalize_options
self.index_url, search_path = self.shadow_path, hosts=hosts,
File "C:\Python34\lib\site-packages\setuptools\package_index.py", line 269, in
__init__
Environment.__init__(self,*args,**kw)
File "C:\Python34\lib\site-packages\pkg_resources.py", line 799, in __init__
self.scan(search_path)
File "C:\Python34\lib\site-packages\pkg_resources.py", line 829, in scan
self.add(dist)
File "C:\Python34\lib\site-packages\pkg_resources.py", line 849, in add
dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
TypeError: unorderable types: str() < NoneType()
Sorry, sometimes its the most obvious things that work...
In this case, simply double clicking the setup.py file from the nltk folder, allowing windows to execute it with python and its installed beautifully.
Try to install it using the following command
C:\Python34\Scripts\nltk-3.0a4>setup.py install
Open Command Prompt (Run as Administrator). Use cd to navigate to the folder in which your downloaded nltk package is present. Then run the command python setup.py install. That's all.
Did you try updating the setuptools package:
pip3 install --upgrade setuptools

ImportError: No module named exceptions

i'm trying to install kitsune in the ubuntu terminal. I am not able to initialize the database. When i give the command ./manage.py syncdb --migrate , i get the following error
Error: Tried importing 'settings_local.py' and 'settings.py' but neither could be found (or they're throwing an ImportError). Please come back and try again later.Traceback (most recent call last):
File "./manage.py", line 30, in <module>
from kitsune import settings # Assumed to be in the same directory.
File "/home/user/kitsune/kitsune/settings.py", line 740, in <module>
import djcelery
File "/usr/local/lib/python2.7/dist-packages/djcelery/__init__.py", line 22, in <module>
from celery import current_app as celery # noqa
File "/usr/local/lib/python2.7/dist-packages/celery/five.py", line 307, in __getattr__
module = __import__(self._object_origins[name], None, None, [name])
File "/usr/local/lib/python2.7/dist-packages/celery/_state.py", line 20, in <module>
from celery.utils.threads import LocalStack
File "/usr/local/lib/python2.7/dist-packages/celery/utils/__init__.py", line 24, in
<module>
from celery.exceptions import CPendingDeprecationWarning, CDeprecationWarning
File "/usr/local/lib/python2.7/dist-packages/celery/exceptions.py", line 13, in <module>
from billiard.exceptions import ( # noqa
ImportError: No module named exceptions
I can't find the exceptions file in billiard. How do I fix this error?
I had this error with fabric. The error message was the same:
ImportError: No module named exceptions
It turned out to be my fabric was out of date. The error was resolved by upgrading fabric to the latest version (1.10) with:
$ sudo pip install fabric --upgrade
For your information, I am running Ubuntu 12.04 64-bit with Python 2.7.3
Exceptions should be a python file in a directory called billiard, for example, you create a file called exceptions.py and add the classes and methods that you need .. this can work around the problem.
You should follow kitsune installation process described in http://kitsune.readthedocs.org/en/latest/hacking_howto.html
There is a link to separate chapter on vendor-packages http://kitsune.readthedocs.org/en/latest/vendor.html#vendor-chapter. You should install all the vendor packages needed by kitsune including billiard and celery (your errors).

Access separate MySQL server from my machine using Python - how? [Mac OS X]

Long story short - I am writing Selenium webdriver Python tests that need to access an external server's MySQL database. I tried installing mysqldb using sudo easy_install MYSQL-python, but I got this message:
EnvironmentError: mysql_config not found` (full (long) traceback below).
I am kind of new to a Python, so I don't fully understand this, but is it saying that I need to have MySQL installed on my local machine? If so, how would I do that, and since I don't need it, is there another way you can recommend? Also, I am running a Mac with Mac OS X Mavericks (10.9).
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 10, in <module>
load_entry_point('setuptools==0.6c12dev-r88846', 'console_scripts', 'easy_install')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 1712, in main
with_ei_usage(lambda:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 1700, in with_ei_usage
return f()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 1716, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 211, in run
self.easy_install(spec, not self.no_deps)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 446, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 476, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 655, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 930, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 919, in run_setup
run_setup(setup_script, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 62, in run_setup
lambda: execfile(
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 105, in run
return func()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 64, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
File "setup.py", line 18, in <module>
File "/tmp/easy_install-Lk4VVX/MySQL-python-1.2.4/setup_posix.py", line 43, in get_config
File "/tmp/easy_install-Lk4VVX/MySQL-python-1.2.4/setup_posix.py", line 25, in mysql_config
EnvironmentError: mysql_config not found
The error message that you're facing is due to the lack of headers on your machine. That is, you're missing some libraries.
If you're on a Debian-based Linux OS, I'd suggest you use the package provided through aptitude:
sudo apt-get install python-mysqldb
On a side note, drop easy install and start using pip.
sudo apt-get install python-pip
If you want to install this module only with pip/another Python dependency manager you'll need to have several tools/libraries installed on your machine in order to build it:
sudo apt-get install python-dev libmysqlclient-dev
sudo pip install MySQL-python