python-3.6

No module named '__main__.demo'; '__main__' is not a package python3

送分小仙女□ 提交于 2019-12-04 08:58:48
If I execute main.py it works fine, the problem is when I execute demo2.py |myPackage |subPackage demo.py demo2.py main.py main.py from ludikDriver.demo2 import demo2_print demo2_print() demo2.py from .demo import demoprint def demo2_print(): print("demo2") demoprint() demo2_print() demo.py def demoprint(): print("demo") Error: from .demo import demoprint ModuleNotFoundError: No module named '__main__.demo'; '__main__' is not a package Should I have __init__.py ? If you drop the . , it should work. demo2.py becomes: from demo import demoprint # instead of `from .demo import demoprint` def

Why isn't __instancecheck__ being called?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 08:08:40
I have the following python3 code: class BaseTypeClass(type): def __new__(cls, name, bases, namespace, **kwd): result = type.__new__(cls, name, bases, namespace) print("creating class '{}'".format(name)) return result def __instancecheck__(self, other): print("doing instance check") print(self) print(other) return False class A(metaclass=BaseTypeClass): pass print(type(A)) print(isinstance(A(), A)) and when I run it on Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32 I get the following output creating class 'A' <class '__main__.BaseTypeClass'> True Why

Installing Python3.6 alongside Python3.7 on Mac

偶尔善良 提交于 2019-12-04 07:25:47
问题 I'm trying to install tensorflow onto a Mac with Python3.7. However, I'm getting the error: $ pip3 -v install tensorflow ... Skipping link https://files.pythonhosted.org/packages/56/7a/c6bca0fe52a94ca508731d8b139e7dbd5a36cddc64c19f422f97e5a853e8/tensorflow-1.10.0rc1-cp36-cp36m-win_amd64.whl#sha256=3ab24374888d6a13d55ce2e3cf4ba0c9cd6f824723313db5322512087525cb78 (from https://pypi.org/simple/tensorflow/); it is not compatible with this Python Could not find a version that satisfies the

Problem with my program about finding factors

和自甴很熟 提交于 2019-12-04 05:42:52
问题 This was a continuation to my older question The program was working fine without the while True: main() if input("Try Again? (Yes/No)").strip().upper() == 'No': break but when i added it, the problem rose I was trying to make the program start by asking the user a number and it shows a factor then i loop it and ask the user if he wants another number and it repeats if the user wants to repeat it def main(): def print_factors(x): print("The factors of",x,"are:") for i in range(1, x + 1): if x

Scheduling a python 3.6 script in using crontab/cron

无人久伴 提交于 2019-12-04 04:55:21
问题 I'm just setting up a cron tab/job on my Cent OS developement server. Within my crontab I have the following. (Ignore the time setting, this was added about 15:32 UTC server time just to get the next scheduled run in). 34 15 * * * cd welcomeclient-0.0.5 && python3.6 main.py In the command line cd welcomeclient-0.0.5 && python3.6 main.py works fine. welcomeclient-0.0.5 is under root in the droplet, and python3.6 is in /usr/bin . Any suggestions? 回答1: Try using absolute paths in your crontab

Python asyncio '_overlapped' is not imported

别等时光非礼了梦想. 提交于 2019-12-04 04:20:27
问题 Could not import asyncio library in virtualenv. Python 3.6.4 x32 Win 10 x64 Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>import asyncio Traceback (most recent call last): File "C:\Python36\Lib\asyncio\__init__.py", line 16, in <module> from . import _overlapped ImportError: cannot import name '_overlapped' During handling of the above exception, another exception occurred:

ElementNotVisibleException when use headless Chrome browser

为君一笑 提交于 2019-12-04 02:01:56
When I run test script in headless mode chrome browser, element link is not visible, is not able to do linkElement.click() . in head mode is everything OK. All other info are in stacktrace. Anyone knows what to do, please? StackTrace: ERROR occurred: Message: element not visible (Session info: headless chrome=60.0.3112.90) (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 x86_64) Traceback (most recent call last): File "C:\nik-x.py", line 148, in main func(nik) File "C:\lib\support.py", line 121, in wrapper raise ret File "C:\lib

Python3.6 AttributeError: module 'asyncio' has no attribute 'run'

半腔热情 提交于 2019-12-03 19:17:24
问题 I tried to read https://hackernoon.com/asynchronous-python-45df84b82434. It's about asynchronous python and I tried the code from this, but I'm getting a weird Error. The code is: ` import asyncio import aiohttp urls = ['http://www.google.com', 'http://www.yandex.ru', 'http://www.python.org'] async def call_url(url): print('Starting {}'.format(url)) response = await aiohttp.ClientSession().get(url) data = await response.text() print('{}: {} bytes: {}'.format(url, len(data), data)) return data

Why were literal formatted strings (f-strings) so slow in Python 3.6 alpha? (now fixed in 3.6 stable)

╄→尐↘猪︶ㄣ 提交于 2019-12-03 18:46:29
问题 I've downloaded a Python 3.6 alpha build from the Python Github repository, and one of my favourite new features is literal string formatting. It can be used like so: >>> x = 2 >>> f"x is {x}" "x is 2" This appears to do the same thing as using the format function on a str instance. However, one thing that I've noticed is that this literal string formatting is actually very slow compared to just calling format . Here's what timeit says about each method: >>> x = 2 >>> timeit.timeit(lambda: f

In-place custom object unpacking different behavior with __getitem__ python 3.5 vs python 3.6

a 夏天 提交于 2019-12-03 13:23:55
a follow-up question on this question : i ran the code below on python 3.5 and python 3.6 - with very different results: class Container: KEYS = ('a', 'b', 'c') def __init__(self, a=None, b=None, c=None): self.a = a self.b = b self.c = c def keys(self): return Container.KEYS def __getitem__(self, key): if key not in Container.KEYS: raise KeyError(key) return getattr(self, key) def __str__(self): # python 3.6 # return f'{self.__class__.__name__}(a={self.a}, b={self.b}, c={self.c})' # python 3.5 return ('{self.__class__.__name__}(a={self.a}, b={self.b}, ' 'c={self.c})').format(self=self) data0 =