sys

knitr - error when importing python module

一个人想着一个人 提交于 2019-12-01 02:48:36
I am having trouble when running the python engine in knitr. I can import some modules but not others. For example I can import numpy but not pandas. {r, engine='python'} import pandas I get the error. Quitting from lines 50-51 (prepayment.Rmd) Error in (knit_engines$get(options$engine))(options) : Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pandas Calls: <Anonymous> ... process_group.block -> call_block -> block_exec -> in_dir -> <Anonymous> In addition: Warning message: running command ''python' -c 'import pandas' 2>&1' had status 1

Selenium: Quit Python script without closing browser

老子叫甜甜 提交于 2019-11-30 22:52:31
I use the following to handle the situation where Ctrl + C is used to terminate a running Python script. except KeyboardInterrupt: print "ABORTED" However, this also terminates my Selenium WebDriver browser. Is there a way to terminate the script and keep the browser alive, so that I can continue using it? What I usually do instead, is to pause the script via Ctrl + Z . This unfortunately often causes the browser to freeze and not respond. You can replace CTRL+C+ sys.exit() with quit() method to terminate Python script without closing browser session. Just use following form: user_choice = raw

忘记oracle的sys用户密码怎么修改

感情迁移 提交于 2019-11-30 21:05:32
一、忘记除SYS、SYSTEM用户之外的用户的登录密码。 用SYS (或SYSTEM)用户登录: CONN SYS/PASS_WORD AS SYSDBA; 使用如下语句修改用户的密码: ALTER USER user_name IDENTIFIED BY "newpass"; 注意:密码不能全是数字。并且不能是数字开头。否则会出现:ORA-00988: 口令缺失或无效 二、忘记SYS用户,或者是SYSTEM用户的密码。 如果是忘记SYSTEM用户的密码,可以用SYS用户登录。然后用ALTER USER 命令修改密码: CONN SYS/PASS_WORD AS SYSDBA; ALTER USER SYSTEM IDENTIFIED BY "newpass"; 如果是忘记SYS用户的密码,可以用SYSTEM用户登录。然后用ALTER USER 命令修改密码。 CONN SYSTEM/PASS_WORD ; ALTER USER SYSTEM IDENTIFIED BY "newpass"; 三、如果SYS,SYSTEM用户的密码都忘记或是丢失。 可以使用ORAPWD.EXE 工具修改密码。 开始菜单->运行->输入‘CMD’,打开命令提示符窗口,输入如下命令: orapwd file=D:\oracle10g\database\pwdctcsys.ora password

python: sys is not defined

北城余情 提交于 2019-11-30 16:50:42
I have a piece of code which is working in Linux, and I am now trying to run it in windows, I import sys but when I use sys.exit(). I get an error, sys is not defined. Here is the begining part of my code try: import numpy as np import pyfits as pf import scipy.ndimage as nd import pylab as pl import os import heapq import sys from scipy.optimize import leastsq except ImportError: print "Error: missing one of the libraries (numpy, pyfits, scipy, matplotlib)" sys.exit() Why is sys not working?? Move import sys outside of the try - except block: import sys try: # ... except ImportError: # ... If

Why is sys.getdefaultencoding() different from sys.stdout.encoding and how does this break Unicode strings?

一曲冷凌霜 提交于 2019-11-30 09:44:57
I spent a few angry hours looking for the problem with Unicode strings that was broken down to something that Python (2.7) hides from me and I still don't understand. First, I tried to use u".." strings consistently in my code, but that resulted in the infamous UnicodeEncodeError . I tried using .encode('utf8') , but that didn't help either. Finally, it turned out I shouldn't use either and it all works out automagically. However, I (here I need to give credit to a friend who helped me) did notice something weird while banging my head against the wall. sys.getdefaultencoding() returns ascii ,

Selenium: Quit Python script without closing browser

让人想犯罪 __ 提交于 2019-11-30 05:19:55
问题 I use the following to handle the situation where Ctrl + C is used to terminate a running Python script. except KeyboardInterrupt: print "ABORTED" However, this also terminates my Selenium WebDriver browser. Is there a way to terminate the script and keep the browser alive, so that I can continue using it? What I usually do instead, is to pause the script via Ctrl + Z . This unfortunately often causes the browser to freeze and not respond. 回答1: You can replace CTRL+C+ sys.exit() with quit()

How to resolve “ValueError: attempted relative import beyond top-level package”

左心房为你撑大大i 提交于 2019-11-29 12:52:45
I have the following problem with my project, help me please! Here is the structure of my package: /pkg /pkg/__init__.py /pkg/sub1/__init__.py /pkg/sub2/__init__.py /pkg/sub1/foo1.py /pkg/sub2/foo2.py Here is implementation of foo1.py: from ..sub2 import foo2 def f(): print("Hello!") When I run foo1 I get error: ValueError: attempted relative import beyond top-level package . I can solve it doing the following adjustment: import sys import os sys.path.append(os.path.abspath(os.path.pardir)) from sub2 import foo2 def f(): print("Hello!") But I wonder if there is a way to do it without importing

python: sys.argv[0] meaning in official documentation

…衆ロ難τιáo~ 提交于 2019-11-29 11:13:51
Quoting from docs.python.org : " sys.argv The list of command line arguments passed to a Python script. argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command line option to the interpreter, argv[0] is set to the string '-c' . If no script name was passed to the Python interpreter, argv[0] is the empty string." Am I missing something, or sys.argv[0] always returns the script name, and to get '-c' I'd have to use sys.argv[1] ? I'm testing with Python 3.2 on GNU/Linux. No, if you invoke Python with -c

IPython sys.path different from python sys.path

∥☆過路亽.° 提交于 2019-11-29 10:26:55
I generally use IPython and only recently noticed that the the search path for imports is wrong in the regular python shell. From what I understand, sys.path inherits from PYTHONPATH (although I don't know where PYTHONPATH lives), is this different in IPython? I'm worried that this effecting installations. For instance I just tried pip install --upgrade gensim which failed because it couldn't resolve the scipy dependency, which I already have installed. So I dove a little bit deeper and found in Ipython import gensim gensim.__version__ returns .9.1 while in python import gensim gensim._

What does “del sys.modules[module]” actually do?

≯℡__Kan透↙ 提交于 2019-11-29 07:41:13
As everyone knows, you can do del sys.modules[module] to delete an imported module. So I was thinking: how is this different from rewriting sys.modules ? An interesting fact is, rewriting sys.modules can't truely delete a module. # a_module.py print("a module imported") Then import sys def func1(): import a_module # del sys.modules['a_module'] sys.modules = { k: v for k, v in sys.modules.items() if 'a_module' not in k} print('a_module' not in sys.modules) # True def func2(): import a_module func1() # a module imported func2() # no output here If I use del sys.modules['a_module'] , calling