python-3.5

How can I specify rmarkdown to use python3 instead python 2?

与世无争的帅哥 提交于 2021-01-27 02:54:59
问题 I am trying to run python as rmarkdwon code chunks. I was sucessfull but rmarkdown by default uses python2 and I want it to use python 3. I am running it on Ubuntu with python 2.7.6 installed and I installed anaconda with pytthon 3.5, which is the one I want rmarkdown use. Here is the code and output of the python chunk in rmarkdown ```{python} import sys print (sys.version) ``` and the output: 2.7.6 (default, Jun 22 2015, 17:58:13) Any ideas? 回答1: You can add engine.path = '/path/to/python3'

Error running 'filename'. The system cannot find the file specified (PyCharm)

这一生的挚爱 提交于 2021-01-18 06:58:16
问题 I have a PyCharm project on my Windows, where I am able to run most .py files by pressing Ctrl + Shift + F10 (or running the debugger). In one of the files however I get the error Error running 'test': Cannot run program "\opt\anaconda\bin\python" (in directory "..."): CreateProcess error=2, the system cannot find the file specified.` The test.py file right now only contains print('hello') I can do this for the other files, and using 'Execute selection in console' also works fine. Given I am

Django command throws TypeError: handle() got an unexpected keyword argument

做~自己de王妃 提交于 2021-01-02 05:56:18
问题 I'm using Django 1.10.4 and Python 3.52. When I try to run a Django command via python manage.py my_command I get the following error: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "path_to_envs/envs/env_name/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "path_to_envs/envs/env_name/lib/python3.5/site-packages/django/core/management/__init__.py",

Python requests GET takes a long time to respond to some requests

只愿长相守 提交于 2020-12-30 06:04:07
问题 I am using Python requests get method to query the MediaWiki API, but it takes a lot of time to receive the response. The same requests receive the response very fast through a web browser. I have the same issue requesting google.com. Here are the sample codes that I am trying in Python 3.5 on Windows 10: response = requests.get("https://www.google.com") response = requests.get("https://en.wikipedia.org/wiki/Main_Page") response = requests.get("http://en.wikipedia.org/w/api.php?", params={

pytorch, AttributeError: module 'torch' has no attribute 'Tensor'

半世苍凉 提交于 2020-12-29 08:59:26
问题 I'm working with Python 3.5.1 on a computer having CentOS Linux 7.3.1611 (Core) operating system. I'm trying to use PyTorch and I'm getting started with this tutorial. Unfortunately, the #4 line of the example creates troubles: >>> torch.Tensor(5, 3) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'torch' has no attribute 'Tensor' I cannot understand this error... of course in Torch the 'torch' does have an attribute 'Tensor'. The same command

python 3 asyncio: coroutines execution order using run_until_complete(asyncio.wait(corutines_list))

不想你离开。 提交于 2020-12-05 12:14:43
问题 I have what is probably a quite useless question, but nevertheless I feel I am missing something that might be important to understand how asyncio works. I just started to familiarize with asyncio and I wrote this very basic piece of code: import asyncio import datetime from random import randint async def coroutine(i): start = datetime.datetime.now() print('coroutine {} started.'.format(i)) n = randint(1, 11) await asyncio.sleep(n) end = datetime.datetime.now() print('coroutine {} finished

python 3 asyncio: coroutines execution order using run_until_complete(asyncio.wait(corutines_list))

痴心易碎 提交于 2020-12-05 12:11:20
问题 I have what is probably a quite useless question, but nevertheless I feel I am missing something that might be important to understand how asyncio works. I just started to familiarize with asyncio and I wrote this very basic piece of code: import asyncio import datetime from random import randint async def coroutine(i): start = datetime.datetime.now() print('coroutine {} started.'.format(i)) n = randint(1, 11) await asyncio.sleep(n) end = datetime.datetime.now() print('coroutine {} finished

autoplay first video in results of youtube using python

人走茶凉 提交于 2020-11-29 09:14:15
问题 I want to make an app where I search by typing a certain keyword and the program automatically plays the first video in the search results on youtube. How do I get the link for the first video of the search result? 回答1: this code is to prints the link of the first video on a search result you provide to the app.. example :- run the app .. type hello its me .. then it does it magic. import urllib.request import urllib.parse import re import webbrowser as wb query_string = urllib.parse

Python not interning strings when in interactive mode?

五迷三道 提交于 2020-11-29 04:22:48
问题 When in a Python interactive session: In [1]: a = "my string" In [2]: b = "my string" In [3]: a == b Out[3]: True In [4]: a is b Out[4]: False In [5]: import sys In [6]: print(sys.version) 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] On the other hand, when running the following program: #!/usr/bin/env python import sys def test(): a = "my string" b = "my string" print(a == b) print(a is b) if __name__ == "__main__": test() print(sys.version) The output is: True True 3.5.2

Python not interning strings when in interactive mode?

只谈情不闲聊 提交于 2020-11-29 04:21:26
问题 When in a Python interactive session: In [1]: a = "my string" In [2]: b = "my string" In [3]: a == b Out[3]: True In [4]: a is b Out[4]: False In [5]: import sys In [6]: print(sys.version) 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] On the other hand, when running the following program: #!/usr/bin/env python import sys def test(): a = "my string" b = "my string" print(a == b) print(a is b) if __name__ == "__main__": test() print(sys.version) The output is: True True 3.5.2