python-3.5

Change mod_wsgi from python3.5 to 3.6

微笑、不失礼 提交于 2019-12-05 13:02:39
I have a flask app that used to run with python3.5 on apache2. I am now trying to change it to run on 3.6 (i have sone type hinting in my code that is only supported on 3.6). I have installed the module for python3.6, but when tried to restart apache and run my app, it fails. When running mod_wsgi-express module-location I have the python3.5 version /usr/local/lib/python3.5/dist-packages/mod_wsgi/server/mod_wsgi-py35.cpython-35m-x86_64-linux-gnu.so The same file also existis on my server in python3.6 dir. I also changed my $PATH to run python3.6 as a default for python. How can I tell apache

Tf.Print() doesn't print the shape of the tensors?

不羁的心 提交于 2019-12-05 11:48:00
I have written a simple classification program using Tensorflow and getting the output except I tried to print the shape of tensors for Model parameters, features & bias. The function definations: import tensorflow as tf, numpy as np from tensorflow.examples.tutorials.mnist import input_data def get_weights(n_features, n_labels): # Return weights return tf.Variable( tf.truncated_normal((n_features, n_labels)) ) def get_biases(n_labels): # Return biases return tf.Variable( tf.zeros(n_labels)) def linear(input, w, b): # Linear Function (xW + b) # return np.dot(input,w) + b return tf.add(tf

Using Mocks inside Doctests?

假装没事ソ 提交于 2019-12-05 09:45:15
I am using doctests. I am wondering what is the correct way to doctest a function that performs an external action (e.g. sends email, connects to a server, etc)? Using Mock seems like the answer but it will muddy up the doc string of the function. For example: class SSHConnection(BaseConnection): """Provides basic SSH functions. >>> host = '127.0.0.1' >>> port = 22 >>> username = 'user' >>> password = 'password' >>> ssh = SSHConnection(host, username, password, port) >>> ssh.execute('uname -a') """ ... 来源: https://stackoverflow.com/questions/41289247/using-mocks-inside-doctests

Cannot install pymssql on windows

空扰寡人 提交于 2019-12-05 08:34:04
i am trying to install pymssql as pip install pymssql i have windows 7 and python 3.5 (from anaconda) but i get Failed building wheel for pymssql i believe its related to freetds and python-dev . how do i install these on windows? Which packages would i need to install? this pip install worked just fine for python 2.7. If the pip does not work,is there any other way i can download and install pymssql? Jason Sperske I just went through this small bit of hell and finally got things working, here is what I ended up doing: First locate your Python directory (for me it was c:\Python35 ), then

Event loop created by asyncio.new_event_loop hangs

て烟熏妆下的殇ゞ 提交于 2019-12-05 08:19:26
The following code just hangs without ever printing anything: import asyncio async def foo(loop): print('foo') loop.stop() loop = asyncio.new_event_loop() asyncio.ensure_future(foo(loop)) loop.run_forever() If I use get_event_loop everything works fine. Is there something I'm doing wrong or have I stumbled upon a bug? I'm using Python 3.5.1. asyncio.AbstractEventLoopPolicy.new_event_loop documentation says: If there’s need to set this loop as the event loop for the current context, set_event_loop() must be called explicitly. import asyncio async def foo(loop): print('foo') loop.stop() loop =

Python 3.5 pip 9 AttributeError: 'NoneType' object has no attribute 'bytes'

隐身守侯 提交于 2019-12-05 08:00:21
What is the problem? I tried " python -m pip install -U pip " and " python -m pip install --upgrade pip " both with the same error (and " pip install -U --force-reinstall pip "). what should I do? C:\Users\Peyman\PycharmProjects\untitled3>python -m pip install -U pip Collecting pip Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 9.0.3 Uninstalling pip-9.0.3: Successfully uninstalled pip-9.0.3 Rolling back uninstall of pip

cxfreeze aiohttp cannot import compat

女生的网名这么多〃 提交于 2019-12-05 06:52:10
I'm trying to use cx_freeze to build a binary dist for an web application written in Python 3 using the aiohttp package. Basically I did: cxfreeze server.py and got a dist output But when running the ./server binary, I got the following message: File "/usr/local/lib/python3.5/dist-packages/cx_Freeze/initscripts/__startup__.py", line 12, in <module> __import__(name + "__init__") File "/usr/local/lib/python3.5/dist-packages/cx_Freeze/initscripts/Console.py", line 24, in <module> exec(code, m.__dict__) File "server.py", line 1, in <module> File "/usr/local/lib/python3.5/dist-packages/aiohttp/_

Python 3.5.1 : NameError: name 'json' is not defined

半世苍凉 提交于 2019-12-05 04:38:04
#!/usr/bin/env python # encoding: utf-8 import tweepy #https://github.com/tweepy/tweepy import json as simplejson #write tweet objects to JSON file = open('tweet.json', 'wb') print ("Writing tweet objects to JSON please wait...") for status in alltweets: json.dump(status._json,file,sort_keys = True,indent = 4) #close the file print ("Done") file.close() if __name__ == '__main__': #pass in the username of the account you want to download get_all_tweets("@AlertZaAfrica") The python compiler says line 54 is wrong. I already defined import json as simplejson. The above area where I defined import

Python scan for WiFi

≯℡__Kan透↙ 提交于 2019-12-05 02:50:20
问题 I was searching for a program that can scan for WiFi networks and print all of the SSIDs. I tried with scapy but I failed. I am using the pyCharm editor. I tried this code: from scapy.all import * from scapy.layers.dot11 import Dot11 def packet_handler(pkt): if pkt.haslayer(Dot11) and pkt.type == 2: print(pkt.show()) scapy.sniff(iface="mon0", prn=packet_handler) 回答1: try pip install wifi then for scanning use from wifi import Cell, Scheme Cell.all('wlan0') This returns a list of Cell objects.

Heroku: No default language could be detected for this app for python even with runtime.txt

断了今生、忘了曾经 提交于 2019-12-05 02:47:10
I am trying to deploy a project to heroku and I am getting this error:- Counting objects: 70, done. Delta compression using up to 4 threads. Compressing objects: 100% (64/64), done. Writing objects: 100% (70/70), 17.36 KiB | 0 bytes/s, done. Total 70 (delta 23), reused 3 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: ! No default language could be detected for this app. remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. remote: See https://devcenter.heroku.com/articles/buildpacks remote: