running pip gives UnicodeEncodeError - django

I just reinstalled python and pip, but when i run the command pip i should expect to see the help info for pip commands. instead i get this:
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 9, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 210, in main
cmd_name, cmd_args = parseopts(args)
File "C:\Python27\lib\site-packages\pip\__init__.py", line 165, in parseopts
parser.print_help()
File "C:\Python27\lib\optparse.py", line 1670, in print_help
file.write(self.format_help().encode(encoding, "replace"))
File "C:\Python27\lib\optparse.py", line 1650, in format_help
result.append(self.format_option_help(formatter))
File "C:\Python27\lib\optparse.py", line 1633, in format_option_help
result.append(group.format_help(formatter))
File "C:\Python27\lib\optparse.py", line 1114, in format_help
result += OptionContainer.format_help(self, formatter)
File "C:\Python27\lib\optparse.py", line 1085, in format_help
result.append(self.format_option_help(formatter))
File "C:\Python27\lib\optparse.py", line 1074, in format_option_help
result.append(formatter.format_option(option))
File "C:\Python27\lib\optparse.py", line 316, in format_option
help_text = self.expand_default(option)
File "C:\Python27\lib\site-packages\pip\baseparser.py", line 110, in expand_de
fault
return optparse.IndentedHelpFormatter.expand_default(self, option)
File "C:\Python27\lib\optparse.py", line 288, in expand_default
return option.help.replace(self.default_tag, str(default_value))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 11:
ordinal not in range(128)
i have had python 3.4 installed before this but wanted to change to 2.7. on 3.4 pip were running fine, but there were some issues with django on python3.4
edit: user folder contains non-ascii character. This worked with python 3.4 but not with 2.7

Created a new user with ascii compliant characters. Pip now works fine with no errors.

Related

IronPython: impossible to use pip

In the last two weeks I noticed that my ironpython installation is not able to use pip anymore, e.g.:
ipy.exe -m pip install <package>
the stacktrace is similar to the following:
File "<path_to_bin>\bin\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "<path_to_bin>\bin\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "<path_to_bin>\bin\lib\site-packages\pip\req\req_set.py", line 376, in prepare_files
discovered_reqs.extend(self._prepare_file(
File "<path_to_bin>\bin\lib\site-packages\pip\req\req_set.py", line 551, in _prepare_file
req_to_install.populate_link(
File "<path_to_bin>\bin\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "<path_to_bin>\bin\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "<path_to_bin>\bin\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "<path_to_bin>\bin\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "<path_to_bin>\bin\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "<path_to_bin>\bin\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "<path_to_bin>\bin\lib\site-packages\pip\index.py", line 728, in __init__
self.parsed = html5lib.parse(
File "<path_to_bin>\bin\lib\site-packages\pip\_vendor\html5lib\html5parser.py", line 35, in parse
if self.data.matchBytes(key):
File "<path_to_bin>\bin\lib\site-packages\pip\_vendor\html5lib\_inputstream.py", line 668, in matchBytes
data = self[p:p + len(bytes)]
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
for any package, even trying to update pip itself.
I currently use ironpython 2.7.12, but it seems to fail the same way with the beta 3.4. I install pip with the ensurepip module, which corresponds to pip-19.2.3 setuptools-41.2.0

conda build failing with need_source_download message

I successfully built a package on the same Ubuntu desktop 2 months ago and am running into an error building the next version of the same package. I've updated the recipe and made sure conda itself was up-to-date before running the build as usual:
(base) pmena#pmena-7080=> cd anaconda_build/
(base) pmena#pmena-7080=> conda build mi-instrument
No numpy version specified in conda_build_config.yaml. Falling back to default numpy value of 1.11
WARNING:conda_build.metadata:No numpy version specified in conda_build_config.yaml. Falling back to default numpy value of 1.11
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Attempting to finalize metadata for mi-instrument
INFO:conda_build.metadata:Attempting to finalize metadata for mi-instrument
Traceback (most recent call last):
File "/home/pmena/miniconda2/bin/conda-build", line 11, in <module>
sys.exit(main())
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/cli/main_build.py", line 474, in main
execute(sys.argv[1:])
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/cli/main_build.py", line 465, in execute
verify=args.verify, variants=args.variants)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/api.py", line 209, in build
notest=notest, need_source_download=need_source_download, variants=variants)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/build.py", line 2863, in build_tree
notest=notest,
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/build.py", line 1837, in build
output_metas = expand_outputs([(m, need_source_download, need_reparse_in_env)])
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/render.py", line 757, in expand_outputs
for (output_dict, m) in _m.copy().get_output_metadata_set(permit_unsatisfiable_variants=False):
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/metadata.py", line 2054, in get_output_metadata_set
bypass_env_check=bypass_env_check)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/metadata.py", line 727, in finalize_outputs_pass
permit_unsatisfiable_variants=permit_unsatisfiable_variants)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/render.py", line 538, in finalize_metadata
exclude_pattern)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/render.py", line 390, in add_upstream_pins
permit_unsatisfiable_variants, exclude_pattern)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/render.py", line 378, in _read_upstream_pin_files
permit_unsatisfiable_variants=permit_unsatisfiable_variants)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/render.py", line 154, in get_env_dependencies
channel_urls=tuple(m.config.channel_urls))
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/environ.py", line 749, in get_install_actions
locking=locking, timeout=timeout)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/index.py", line 172, in get_build_index
update_index(output_folder, verbose=debug)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/index.py", line 273, in update_index
current_index_versions=current_index_versions)
File "/home/pmena/miniconda2/lib/python2.7/site-packages/conda_build/index.py", line 776, in index
with tqdm(total=len(subdirs), disable=(verbose or not progress), leave=False) as t:
AttributeError: __exit__
This has always been a relatively straightforward process, so I'm hoping that it's just a simple oversight. Thanks in advance!
I ended up installing a slightly older version of miniconda2, which I was able to find in the anaconda archives. The build completed successfully after that.

How to fix 'ORA-19011' error in Python cx_Oracle

HI~ I want to query xml data from Oracle db with cx_Oracle, but it doesn't work with Ora-19011 error message. I think size of query data is larger than string buffer, but i don't know how to solve this problem
Oracle DB is an external DB and it's not my own DB, So i can't access directly. Therefore, I want to fix my problem on my code and print query data on python terminal.
(my software version)
windows 10 64bit
python 2.7 64bit
oracle-instant client 19.3 64bit
cx_oracle 7.2.2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cx_Oracle
import sys
import csv
import codecs
printHeader = True
conn = cx_Oracle.connect('id/passwd#ip:port/orcl')
print(conn.version)
curs = conn.cursor()
curs.execute('SELECT * FROM tablename')
for record in curs:
print(record)
Error occured at line 18(for record in curs) and here are error messages.
11.2.0.4.0
We've got an error while stopping in unhandled exception: <class 'cx_Oracle.DatabaseError'>.
Traceback (most recent call last):
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 1740, in do_stop_on_unhandled_exception
self.do_wait_suspend(thread, frame, 'exception', arg, is_unhandled_exception=True)
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 1615, in do_wait_suspend
with self._threads_suspended_single_notification.notify_thread_suspended(thread_id, stop_reason):
File "C:\Python27\lib\contextlib.py", line 17, in __enter__
return self.gen.next()
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 360, in notify_thread_suspended
with AbstractSingleNotificationBehavior.notify_thread_suspended(self, thread_id, stop_reason):
File "C:\Python27\lib\contextlib.py", line 17, in __enter__
return self.gen.next()
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 308, in notify_thread_suspended
self.send_suspend_notification(thread_id, stop_reason)
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 354, in send_suspend_notification
py_db.writer.add_command(py_db.cmd_factory.make_thread_suspend_single_notification(py_db, thread_id, stop_reason))
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_net_command_factory_json.py", line 309, in make_thread_suspend_single_notification
return NetCommand(CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, 0, event, is_json=True)
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_net_command.py", line 57, in __init__
text = json.dumps(as_dict)
File "C:\Python27\lib\json\__init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "C:\Python27\lib\json\encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Python27\lib\json\encoder.py", line 270, in iterencode
return _iterencode(o, 0)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb9 in position 11: invalid start byte
Traceback (most recent call last):
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\goo41\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Python27\lib\runpy.py", line 252, in run_path
return _run_module_code(code, init_globals, run_name, path_name)
File "C:\Python27\lib\runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "c:\PythonWorkspace\oraclePrc\test1.py", line 18, in <module>
for record in curs:
cx_Oracle.DatabaseError: ORA-19011: Character string buffer too small
When you connect to the database, try using this code instead:
conn = cx_Oracle.connect('id/passwd#ip:port/orcl', encoding="UTF-8", nencoding="UTF-8")
This will ensure that you are using a universal encoding -- which may eliminate the first error, and possibly the second as well. If not, adjust the code sample and error messages noted above.

Hive installation fails on Hadoop 2.7.3 through amabari

I am trying to install hive on hadoop 2.7.2 with hdp 2.5. My ambari version is 2.4. Every other component is working fine (HDFS,YARN, MR2, ZOOKEEPER etc.).
When i am trying to install hive with new MySql database through ambari UI it give me following error for HCat client installation:
Traceback (most recent call last): File "/var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py", line 85, in <module>
HCatClient().execute() File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 280, in execute
method(env) File "/var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hcat_client.py", line 35, in install
self.install_packages(env) File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 567, in install_packages
retry_count=agent_stack_retry_count) File "/usr/lib/python2.6/site-packages/resource_management/core/base.py", line 155, in __init__
self.env.run() File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 160, in run
self.run_action(resource, action) File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 124, in run_action
provider_action() File "/usr/lib/python2.6/site-packages/resource_management/core/providers/package/__init__.py", line 54, in action_install
self.install_package(package_name, self.resource.use_repos, self.resource.skip_repos) File "/usr/lib/python2.6/site-packages/resource_management/core/providers/package/yumrpm.py", line 49, in install_package
self.checked_call_with_retries(cmd, sudo=True, logoutput=self.get_logoutput()) File "/usr/lib/python2.6/site-packages/resource_management/core/providers/package/__init__.py", line 83, in checked_call_with_retries
return self._call_with_retries(cmd, is_checked=True, **kwargs) File "/usr/lib/python2.6/site-packages/resource_management/core/providers/package/__init__.py", line 91, in _call_with_retries
code, out = func(cmd, **kwargs) File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 71, in inner
result = function(command, **kwargs) File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 93, in checked_call
tries=tries, try_sleep=try_sleep) File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 141, in _call_wrapper
result = _call(command, **kwargs_copy) File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 294, in _call
raise Fail(err_msg) resource_management.core.exceptions.Fail: Execution of '/usr/bin/yum -d 0 -e 0 -y install hive_2_5_0_0_1245' returned 1. Error unpacking rpm package hive_2_5_0_0_1245-1.2.1000.2.5.0.0-1245.el6.noarch error: unpacking of archive failed on file /usr/hdp/2.5.0.0-1245/hive/conf: cpio: rename failed - Is a directory

setuptools ez_setup return me UnicodeDecodeError

I'm using python 3.3 and Windows XP(32x).
I tried to install setuptools.
I write in command line:
py ez_setup.py install
And it return me error:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
exec(init_file.read(), command_ns)
File "<string>", line 8, in <module>
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\_
init__.py", line 12, in <module>
from setuptools.extension import Extension
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\e
tension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\d
st.py", line 16, in <module>
from setuptools.compat import numeric_types, basestring
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\c
mpat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHan
ler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9e in position 6: ordinal
not in range(128)
Something went wrong during the installation.
See the error message above.
I am also using python 2.7, but I want to install setuptools for python 3.3.
I open my file with IDE and run it(because if you run code from cmd and you have both python2 and python3 it will run with python2 and iif you run it from IDE for python3 it will run in python3).
I really don't know if my explanation is true(because I don't have python2 on path), but I know that some files only work when you run it with IDE, and some only with cmd(or graphical).