Install configparser error on windows 7 - python

When i install module configparser on windows 7 using command "pip install ConfigParser", I receive an error:
SyntaxError: invalid syntax
E:\KIENNH\projects\Projs\acs>pip install ConfigParser
Downloading/unpacking ConfigParser Downloading
configparser-3.3.0r2.tar.gz Running setup.py
(path:C:***\ConfigParser\setup.py) egg_info for package ConfigParser
Traceback (most recent call last):
File "", line 3, in
File "C:\Python34\lib\site-packages\setuptools__init__.py", line 5, in
import distutils.core
File "C:\Python34\lib\distutils\core.py", line 18, in
from distutils.config import PyPIRCCommand
File "C:\Python34\lib\distutils\config.py", line 7, in
from configparser import ConfigParser
File "C:***\ConfigParser\configparser.py", line 397
_KEYCRE = re.compile(ur"%(([^)]+))s")
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 3, in
File "C:\Python34\lib\site-packages\setuptools__init__.py", line 5,
in
import distutils.core
File "C:\Python34\lib\distutils\core.py", line 18, in
from distutils.config import PyPIRCCommand
File "C:\Python34\lib\distutils\config.py", line 7, in
from configparser import ConfigParser
File "C:***\configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax
Ps: I have found a similar question here, but there no answer!:
https://github.com/flyingrub/scdl/issues/8

configparser is included in the standard library.
https://docs.python.org/3/library/configparser.html
Just use import configparser

Related

import versioneer gives SyntaxError on *MATCH_ARGS

python setup.py build --compiler=mingw32
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import versioneer
File "/cygdrive/c/Users/Mansi/Downloads/cvxopt-1.3.0/versioneer.py", line 1194
"--always", "--long", *MATCH_ARGS],
^
SyntaxError: invalid syntax
Does anyone happen to know why this error is coming?

Syntax Error:Invalid syntax when installing django in cent os 6.9

I am getting the following error when executing this command "sudo pip install django"
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/lib/python2.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/lib/python2.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/lib/python2.6/site-packages/pip/_internal/index.py", line 526
{str(c.version) for c in all_candidates},
^
SyntaxError: invalid syntax
And python installed version is Python 2.7.11 using this command python -V

How to install packages on portable python

Good morning,
i'm trying to install a package on portable python. I found that i do not have the easy_install.exe file, I just have the easy_install.py file.
I tried the following from prompt_CDOS:
1)
C:\Software\Portable Python 3.2.5.1>app\py
thon.exe textract-1.6.1.tar\textract-1.6.1\setup.py
Traceback (most recent call last):
File "textract-1.6.1.tar\textract-1.6.1\setup.py", line 4, in <module>
from setuptools import setup
File "C:\Software\Portable Python 3.2.5.
1\app\lib\site-packages\setuptools\__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "C:\Software\Portable Python 3.2.5.
1\app\lib\site-packages\setuptools\extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Software\Portable Python 3.2.5.
1\app\lib\site-packages\setuptools\dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
2)
C:\Software\Portable Python 3.2.5.1>App\py
thon.exe App\easy_install.py textract-1.6.1.tar\textract-1.6.1\setup.py
Traceback (most recent call last):
File "App\easy_install.py", line 4, in <module>
from setuptools.command.easy_install import main
File "C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
any suggestion?
thanks
The syntax
except ValueError, e:
^
SyntaxError: invalid syntax
is for Python 2. The error is from the file C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\dist.py. It seems you have a wrong version of setuptools installed. You have setuptools for Py2 but you need setuptools for Py3.

configparser not working in Python 3.4, NoSectionError but works fine in PyCharm

I worked on a Python 3.4 script in PyCharm 4.5. (repo: https://github.com/Djidiouf/bbot )
In it, I used import configparser without any problem for retrieving some values in a config.cfg:
config = configparser.RawConfigParser()
config.read('config.cfg')
server = config.get('bot_configuration', 'server')
channel = config.get('bot_configuration', 'channel')
botnick = config.get('bot_configuration', 'botnick')
port = config.getint('bot_configuration', 'port')
Now, I want to deploy it on a Debian 8.1 server. On that server, I have both Python 2.7 and Python 3.4 versions installed.
But when I ran the script on the machine, I have the following issue:
djidiouf#linuxserver:/home/djidiouf# /usr/bin/python3.4 /home/djidiouf/bbot/bbot.py
Traceback (most recent call last):
File "/usr/lib/python3.4/configparser.py", line 1116, in _unify_values
sectiondict = self._sections[section]
KeyError: 'bot_configuration'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/djidiouf/bbot/bbot.py", line 25, in <module>
import modules.steam # Contains specific Steam-Valve related functions
File "/home/djidiouf/bbot/modules/steam.py", line 13, in <module>
import modules.connection
File "/home/djidiouf/bbot/modules/connection.py", line 37, in <module>
server = config.get('bot_configuration', 'server')
File "/usr/lib/python3.4/configparser.py", line 754, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.4/configparser.py", line 1119, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'bot_configuration'
I made a lot of research on Internet about that but I didn't find anything valuable. Some people made mention about a corrupt config.cfg file but mine is a LF EOL file with UTF8 without BOM as needed. I also recreated it again with vi on the machine.
I also tried to install configparser with pip (even if, if I understand it well, it's now build-in in Python 3) : pip3 install configparser But when I do that, I have the following error:
djidiouf#linuxserver:/home/djidiouf# sudo pip3 install -v configparser
[sudo] password for djidiouf:
Downloading/unpacking configparser
Ignoring link https://pypi.python.org/packages/source/c/configparser/configparser-3.5.0b1.tar.gz#md5=d60ca2c714acb4adaf5818c6a1ffd78b (from https://pypi.python.org/simple/configparser/), version 3.5.0b1 is a pre-release (use --pre to allow).
Ignoring link https://pypi.python.org/packages/source/c/configparser/configparser-3.5.0b2.tar.gz#md5=ad2a71db8bd9a017ed4735eac7acfa07 (from https://pypi.python.org/simple/configparser/), version 3.5.0b2 is a pre-release (use --pre to allow).
Using version 3.3.0r2 (newest of versions: 3.3.0r2, 3.3.0r1, 3.2.0r3, 3.2.0r2, 3.2.0r1)
Downloading configparser-3.3.0r2.tar.gz
Downloading from URL https://pypi.python.org/packages/source/c/configparser/configparser-3.3.0r2.tar.gz#md5=dda0e6a43e9d8767b36d10f1e6770f09 (from https://pypi.python.org/simple/configparser/)
Running setup.py (path:/tmp/pip-build-v7av3db7/configparser/setup.py) egg_info for package configparser
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>
import distutils.core
File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>
from distutils.config import PyPIRCCommand
File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>
from configparser import ConfigParser
File "/tmp/pip-build-v7av3db7/configparser/configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>
import distutils.core
File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>
from distutils.config import PyPIRCCommand
File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>
from configparser import ConfigParser
File "/tmp/pip-build-v7av3db7/configparser/configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-v7av3db7/configparser
Exception information:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1230, in prepare_files
req_to_install.run_egg_info()
File "/usr/lib/python3/dist-packages/pip/req.py", line 326, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/lib/python3/dist-packages/pip/util.py", line 716, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-v7av3db7/configparser
Storing debug log for failure in /root/.pip/pip.log
Here is a config example, I just changed the values and rename the file accordingly to config.cfg :
[bot_configuration]
server = your.irc.server.com
channel = ##your_channel
botnick = bbot
port = 6667
admins = You,Him
https://github.com/Djidiouf/bbot/blob/master/config_example.cfg
Finally, I just want to say that everything is working on PyCharm 4.5, I just made a git clone, rename the config_example.cfg, change the values, tried to run the script with Python 3.4.
The install error is from _KEYCRE = re.compile(ur"%\(([^)]+)\)s"), that is causing a syntax error as the ur prefix is not supported in python3, pip is trying to instal a python2 package.
Your first error is a keyError 'bot_configuration' which is not because of not having configparser installed, configparser is part of the standard library.
The bot_configuration KeyError is because python cannot find your config file, if you use config.read('foobar') in pycharm you will see the exact same output
I figured out that I had some inconsistency about running the script. When I was in another folder than my script, nothing worked but when I was in it, it worked. Perhaps because the config file is shared and used in the main script and in a module.
In fact it's due to the need to have an absolute path in config.read('/some/path/file.cfg')
Finally, I find that answer: https://stackoverflow.com/a/13800583/3301370
So here is the solution in the case of config.cfg being on the project root directory /config.cfg :
/bbot.py
import os
config.read(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'config.cfg'))
However, as the config file is shared and used in the main script and in a subpath, module, a correct path must be set for the sub module too:
/modules/connection.py
import os
config.read(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'config.cfg'))
It works fine in PyCharm because when you hit the run button for your script, it runs it with the path of the project. The fact that having a relative path for both config.read() statements worked only because of that.
The problem with installing configparser with pip is unrelated to that specific problem and can be ignore in that case as configparser is a built-in library in Python3.

pip install rauth fails : syntax error

I just installed Python 3.3 and then I tried to install rauth by issuing the command:
pip install rauth
and I get this error:
Downloading/unpacking rauth
Running setup.py egg_info for package rauth
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\pipul\appdata\local\temp\pip-build-pipul\rauth\setup.py", l
ine 4, in <module>
from rauth import __version__
File ".\rauth\__init__.py", line 30, in <module>
from .service import OAuth1Service, OAuth2Service, OflyService
File ".\rauth\service.py", line 23
except KeyError, e: # pragma: no cover
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\pipul\appdata\local\temp\pip-build-pipul\rauth\setup.py", line 4, in <module>
from rauth import __version__
File ".\rauth\__init__.py", line 30, in <module>
from .service import OAuth1Service, OAuth2Service, OflyService
File ".\rauth\service.py", line 23
except KeyError, e: # pragma: no cover
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1 in c:\users\pipul\appd
ata\local\temp\pip-build-pipul\rauth
Storing complete log in C:\Users\pipul\pip\pip.log
## Heading ##c:\Python33\Scripts>
Similarly installing oauth2 also fails. But installing selenium succeeds.
Now what could be the thing that is causing this failure?
Thanks in advance.
Like many packages, rauth currently does not support Python 3. However, it looks like there is a branch where they are working on it. See here.
In general, you may have more luck installing packages if you use Python 2.7.

Categories