python-2to3

TypeError: a bytes-like object is required, not 'str' - python 2 to 3 [duplicate]

☆樱花仙子☆ 提交于 2019-11-30 08:34:18
This question already has an answer here: Why do I need 'b' to encode a string with Base64? 6 answers Hi I am having trouble with this error message. I am new to Python and this Python2 and Python3 is a hassle. I'm not sure what to do here, the error message is as shown below. Using Ticker: AAPL Traceback (most recent call last): File "realtime.py", line 18, in <module> r=requests.get(auth_url, headers={"Authorization": "Basic %s" % base64.b64encode(os.environ['INTRINIO_USER'] + ":" + os.environ['INTRINIO_PASSWORD'])}) File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\base64.py

BeautifulSoup4 can't be installed in python3.5 on Windows7

六眼飞鱼酱① 提交于 2019-11-29 22:59:22
问题 I have downloaded beautifulsoup4-4.5.3.tar.gz from https://www.crummy.com/software/BeautifulSoup/bs4/download/4.5/ and unzipped it to my python work directory(which is not my python install directory). However, when I run from bs4 import BeautifulSoup in my IDLE the error massage popped out: >>> from bs4 import BeautifulSoup Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> from bs4 import BeautifulSoup File "D:\python\beautifulsoup4-4.5.3\beautifulsoup4-4.5.3\bs4\_

Python 3 writing to a pipe

余生长醉 提交于 2019-11-29 14:05:55
I'm trying to write some code to put data into a pipe, and I'd like the solution to be python 2.6+ and 3.x compatible. Example: from __future__ import print_function import subprocess import sys if(sys.version_info > (3,0)): print ("using python3") def raw_input(*prmpt): """in python3, input behaves like raw_input in python2""" return input(*prmpt) class pipe(object): def __init__(self,openstr): self.gnuProcess=subprocess.Popen(openstr.split(), stdin=subprocess.PIPE) def putInPipe(self,mystr): print(mystr, file=self.gnuProcess.stdin) if(__name__=="__main__"): print("This simple program just

Why does Python 3 need dict.items to be wrapped with list()?

五迷三道 提交于 2019-11-28 21:03:13
I'm using Python 3. I've just installed a Python IDE and I am curious about the following code warning: features = { ... } for k, v in features.items(): print("%s=%s" % (k, v)) Warning is: "For Python3 support should look like ... list(features.items()) " Also there is mention about this at http://docs.python.org/2/library/2to3.html#fixers It also wraps existing usages of dict.items(), dict.keys(), and dict.values() in a call to list. Why is this necessary? You can safely ignore this "extra precautions" warning: your code will work the same even without list in both versions of Python. It

How to use 2to3 tool in windows?

妖精的绣舞 提交于 2019-11-28 20:23:35
I tried to modify the sintax using 2to3 tool by running command python C:\Python32\Tools\scripts\2to3.py neo4j.py and got the output When opening neo4j.py however I noticed there hasn't been anything changed. Below is the block of code where changes (accoridng to output) should be made: try: import json except ImportError: import simplejson as json try: from urllib.parse import quote except ImportError: from urllib import quote try: from . import rest, batch, cypher except ImportError: import rest, batch, cypher except ValueError: import rest, batch, cypher import logging logger = logging

Should we use pandas.compat.StringIO or Python 2/3 StringIO?

旧城冷巷雨未停 提交于 2019-11-28 13:02:53
StringIO is the file-like string buffer object we use when reading pandas dataframe from text, e.g. "How to create a Pandas DataFrame from a string?" Which of these two imports should we use for StringIO (within pandas)? This is a long-running question that has never been resolved over four years. StringIO.StringIO (Python 2) / io.StringIO (Python 3) Advantages: more stable for futureproofing code, but forces us to version-fork, e.g. see code at bottom from EmilH. pandas.compat.StringIO pandas.compat is a 2/3 compatibility package ("without the need for 2to3") introduced back in 0.13.0 (Jan

Python 3 writing to a pipe

你。 提交于 2019-11-28 07:35:50
问题 I'm trying to write some code to put data into a pipe, and I'd like the solution to be python 2.6+ and 3.x compatible. Example: from __future__ import print_function import subprocess import sys if(sys.version_info > (3,0)): print ("using python3") def raw_input(*prmpt): """in python3, input behaves like raw_input in python2""" return input(*prmpt) class pipe(object): def __init__(self,openstr): self.gnuProcess=subprocess.Popen(openstr.split(), stdin=subprocess.PIPE) def putInPipe(self,mystr)

How to use 2to3 properly for python?

こ雲淡風輕ζ 提交于 2019-11-28 06:17:04
I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it. Thanks for any help As it is written on 2to3 docs , to translate an entire project from one directory tree to another, use: $ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode If you don't have 2to3 on your path, you can directly invoke lib2to3 : python -m lib2to3 directory\file.py And as the docs (and other answers) mention, you can use some flags for more customization: the -w flag to enable writeback, which applies the changes

How are you planning on handling the migration to Python 3?

梦想与她 提交于 2019-11-28 04:38:06
I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction: Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished? Have you already started or plan on starting soon? Or do you plan on waiting until the final version comes out to get into full swing? Glyph Here's the general plan for Twisted. I was originally going to blog this, but then I thought: why blog about it when I could get points for it? Wait

Why does Python 3 need dict.items to be wrapped with list()?

和自甴很熟 提交于 2019-11-27 12:40:51
问题 I'm using Python 3. I've just installed a Python IDE and I am curious about the following code warning: features = { ... } for k, v in features.items(): print("%s=%s" % (k, v)) Warning is: "For Python3 support should look like ... list(features.items()) " Also there is mention about this at http://docs.python.org/2/library/2to3.html#fixers It also wraps existing usages of dict.items(), dict.keys(), and dict.values() in a call to list. Why is this necessary? 回答1: You can safely ignore this