python-3.5

choose python kernel in jupyter

假装没事ソ 提交于 2019-12-04 04:14:48
I have installed on Debian Jessie: Python2.7 Python3.5 I have also installed Jupyter via pip2 and pip3 However when I launch jupyter-notebook I can only use python3 as kernel! How can I switch to pyhton2.7 when using Jupyter? I tried this with a fresh Debian 8.5 machine on Digital Ocean. As root, install pip and jupyter from apt, and the development packages, too. apt-get install python-pip python-dev python3-pip python3-dev libzmq3 pip3 install jupyter Add the kernel for Python2 using the ipykernel module. The Python3 kernel is installed, already. pip install ipykernel python2 -m ipykernel

Writing files asynchronously

荒凉一梦 提交于 2019-12-04 03:43:34
问题 I've been trying to create a server-process that receives an input file path and an output path from client processes asynchronously. The server does some database-reliant transformations, but for the sake of simplicity let's assume it merely puts everything to the upper case. Here is a toy example of the server: import asyncio import aiofiles as aiof import logging import sys ADDRESS = ("localhost", 10000) logging.basicConfig(level=logging.DEBUG, format="%(name)s: %(message)s", stream=sys

I am using jupyter notebook, ipython 3 on windows. Whenever i am starting my python 3, i get the “Kernel Dead” message

北慕城南 提交于 2019-12-04 03:39:37
问题 Dead kernel The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened. the above message is shown in notebook dashboard after i start python3. [I 23:07:08.365 NotebookApp] KernelRestarter: restarting kernel (4/5) WARNING:root:kernel 9938cea3-6528-4a27-b4c3-ee906d748bfb restarted Traceback

python typing module missing the Coroutine class in python 3.5

心不动则不痛 提交于 2019-12-04 03:39:12
I am trying to write code which uses the Coroutine class, as described in the typing documentation . It's look like it's available in python 3.5 , but when I am typing to import it throws me an ImportError : In [1]: from typing import Coroutine ImportError: cannot import name 'Coroutine' Then, I tried to run the code in Python 3.6 and it worked fine. Does this class not available in python 3.5 ? If not, why it's appear in the documentation (of python 3.5 in particular)? I tried to run it with python 3.5.2 . The library typing was not official on 3.5, but became official on 3.6. So for older

Can't load mod_wsgi compiled for Python 3

℡╲_俬逩灬. 提交于 2019-12-04 02:13:26
问题 I'm on CentOS and trying to configure Apache to use mod_wsgi compiled against Anaconda Python 3.5. Compiling mod_wsgi seems to go OK: sudo yum install httpd-devel sudo ./configure --with-python=/opt/anaconda/anaconda3/bin/python sudo make ls -l /etc/httpd/modules/mod_wsgi.so -rwxr-xr-x. 1 root root 702205 Mar 2 23:12 /etc/httpd/modules/mod_wsgi.so But when I start the web server it can't seem to find its libraries: sudo service httpd start Starting httpd: httpd: Syntax error on line 221 of

python requests can't find a folder with a certificate when converted to .exe

血红的双手。 提交于 2019-12-04 01:20:39
问题 I have a program that pools ad stats from different marketing systems. Everything works fine untill i convert it to the .exe format and run it. Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 1549, in __call__ return self.func(*args) File "C:\Users\user\Desktop\alg\TSK_7. Marketing\report_gui.py", line 24, in <lambda> ok = tk.Button(root, text="DO NOT PRESS", bg="red", command=lambda:

How to create standalone executable file from python 3.5 scripts?

廉价感情. 提交于 2019-12-04 01:06:16
Most of the programs available only support upto python version 3.4. cosmoscalibur You can use PyInstaller which support python 3.5. To install it with pip execute in terminal: pip install pyinstaller To make the .exe file: pyinstaller --onefile script.py 来源: https://stackoverflow.com/questions/33168229/how-to-create-standalone-executable-file-from-python-3-5-scripts

Raise an exception from a higher level, a la warnings

独自空忆成欢 提交于 2019-12-03 20:01:37
问题 In the module warnings (https://docs.python.org/3.5/library/warnings.html) there is the ability to raise a warning that appears to come from somewhere earlier in the stack: warnings.warn('This is a test', stacklevel=2) Is there an equivalent for raising errors? I know I can raise an error with an alternative traceback, but I can't create that traceback within the module since it needs to come from earlier. I imagine something like: tb = magic_create_traceback_right_here() raise ValueError(

Python type hinting without cyclic imports

时光毁灭记忆、已成空白 提交于 2019-12-03 18:27:44
问题 I'm trying to split my huge class into two; well, basically into the "main" class and a mixin with additional functions, like so: main.py file: import mymixin.py class Main(object, MyMixin): def func1(self, xxx): ... mymixin.py file: class MyMixin(object): def func2(self: Main, xxx): # <--- note the type hint ... Now, while this works just fine, the type hint in MyMixin.func2 of course can't work. I can't import main.py , because I'd get a cyclic import and without the hint, my editor

Making 1 milion requests with aiohttp/asyncio - literally

好久不见. 提交于 2019-12-03 16:33:37
I followed up this tutorial: https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html and everything works fine when I am doing like 50 000 requests. But I need to do 1 milion API calls and then I have problem with this code: url = "http://some_url.com/?id={}" tasks = set() sem = asyncio.Semaphore(MAX_SIM_CONNS) for i in range(1, LAST_ID + 1): task = asyncio.ensure_future(bound_fetch(sem, url.format(i))) tasks.add(task) responses = asyncio.gather(*tasks) return await responses Because Python needs to create 1 milion tasks, it basically just lags and then prints Killed