python-3.4

Python TypeError: 'float' object cannot be interpreted as an integer

↘锁芯ラ 提交于 2019-11-29 12:58:13
My code: for i in range( 3.3, 5 ): print( i ) The above code have to print: 3.300000 4.300000 but the interpreter of Python 3.4.0 printed the following error: TypeError: 'float' object cannot be interpreted as an integer range() works with integers not floats, but you can build your own range generator which will do what you want: def frange(start, stop, step=1): i = start while i < stop: yield i i += step for i in frange(3.3, 5) will give you the desired result. Note though, that frange will, unlike range but like xrange , return a generator rather than a list. 来源: https://stackoverflow.com

PermissionError [errno 13] when running openpyxl python script in Komodo

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 12:02:24
I am having trouble using openpyxl scripts in Komodo edit 9 and python 3.4 on Windows 7. I copied some openpyxl code to learn, but it won't execute from Komodo. I receive a permission error 13. I checked my path and python34 is present. The same script will run when I use IDLE or Command Prompt. My Komodo command is currently: %(python3) -u %F Any ideas on what may be causing this issue? The code and error are included below from openpyxl import Workbook from openpyxl.compat import range from openpyxl.cell import get_column_letter wb = Workbook() dest_filename = 'empty_book.xlsx' ws1 = wb

How to stream stdout/stderr from a child process using asyncio, and obtain its exit code after?

邮差的信 提交于 2019-11-29 11:55:29
Under Python 3.4 on Windows, I need to stream data written to stdout/stderr by a child process, i.e. receive its output as it occurs, using the asyncio framework introduced in Python 3.4. I also have to determine the program's exit code afterwards. How can I do this? aknuds1 The solution I've come up with so far uses SubprocessProtocol to receive output from the child process, and the associated transport to get the process' exit code. I don't know if this is optimal though. I've based my approach on an answer to a similar question by J.F. Sebastian . import asyncio import contextlib import os

How to write a numpy array to a csv file?

a 夏天 提交于 2019-11-29 11:22:45
I want to open up a new text file and then save the numpy array to the file. I wrote this bit of code: foo = np.array([1,2,3]) abc = open('file'+'_2', 'w') np.savetxt(abc, foo, delimiter=",") I get this error: TypeError Traceback (most recent call last) <ipython-input-33-fea41927952b> in <module>() 2 model = cool 3 abc = open('file'+'_2', 'w') ----> 4 np.savetxt(abc, foo, delimiter=",") /usr/local/lib/python3.4/site-packages/numpy/lib/npyio.py in savetxt(fname, X, fmt, delimiter, newline, header, footer, comments) 1071 else: 1072 for row in X: -> 1073 fh.write(asbytes(format % tuple(row) +

How to install pandas for Python 3?

邮差的信 提交于 2019-11-29 11:06:31
问题 I try to install pandas for Python 3 by executing the following command: sudo pip3 install pandas As a result I get this: Downloading/unpacking pandas Cannot fetch index base URL https://pypi.python.org/simple/ Could not find any downloads that satisfy the requirement pandas Cleaning up... No distributions at all found for pandas Maybe it is interesting to note that installation for Python 2 works fine. sudo pip install pandas Returns the following: Requirement already satisfied (use -

ImportError: No module named 'queue' while running my app freezed with cx_freeze

有些话、适合烂在心里 提交于 2019-11-29 11:06:17
I am using python 3.4. I am able to run my python script without any problem. But While running my freezed python script , following error have appeared. I am able to freeze my script successfully too with cx_freeze. C:\Program Files (x86)\utils>utils.exe Traceback (most recent call last): File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i n <module> from . import urllib3 File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module> from .connectionpool import ( File "C:\Python34\lib\site-packages\requests\packages\urllib3

Compiling Python 3.4 is not copying pip

…衆ロ難τιáo~ 提交于 2019-11-29 10:45:15
问题 I have compiled Python 3.4 from the sources on Linux Mint, but for some reason it is not copying pip to its final compiled folder (after the make install ). Any ideas? 回答1: Just sorted it out. Here it is how to compile python from the sources. $ ./configure --prefix=/home/user/sources/compiled/python3.4_dev --with-ensurepip=install $ make $ make install If you get "Ignoring ensurepip failure: pip 1.5.4 requires SSL/TLS" error: $ sudo apt-get install libssl-dev openssl $ ls 2to3 idle3 pip3.5

Python - Can't Install Packages: TypeError: unorderable types: NoneType() >= str()

一笑奈何 提交于 2019-11-29 10:39:16
System: Win7 64, Python 3.4, Pycharm 3.0.2, MinGW Whenever I try to install a package, in Pycharm or via command line, I get this: running install running build running build_py running build_ext Traceback (most recent call last): File "C:\Users\MyAccount\Downloads\scandir-master\scandir-master\setup.py", line 48, in <module> 'Programming Language :: Python :: Implementation :: CPython', 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

Python ftplib: Show FTP upload progress

蓝咒 提交于 2019-11-29 09:38:06
问题 I am uploading a large file with FTP using Python 3.4. I would like to be able to show the progress percentage while uploading the file. Here's my code: from ftplib import FTP import os.path # Init sizeWritten = 0 totalSize = os.path.getsize('test.zip') print('Total file size : ' + str(round(totalSize / 1024 / 1024 ,1)) + ' Mb') # Define a handle to print the percentage uploaded def handle(block): sizeWritten += 1024 # this line fail because sizeWritten is not initialized. percentComplete =

ImportError: No module named matplotlib with matplotlib installed

南笙酒味 提交于 2019-11-29 09:27:41
The code line: import matplotlib The error: ImportError: No module named 'matplotlib' The problem: which python3.4 % /usr/bin/python3.4 Where is matplotlib installed? sudo find /usr | grep matplotlib % /usr/lib/pymodules/python2.7/matplotlib/... Some considerations: OS: Linux Mint 17.2 I need to use Python 3.4 Solutions: import sys sys.path.append('/usr/lib/pymodules/python2.7/') (Not happy with this one). Using pip3 install matplotlib or sudo pip3 install matplotlib (Recieving errors, and i dont like this one too). Using sudo apt-get install python-matplotlib (May be the perfect one, but