嗨,我正在尝试在我的Windows机器上运行捆绑安装,它运行正常,直到它到达linecache然后吐出一个巨大的错误:
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.2)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.26)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.17)
Using actionmailer (3.0.3)
Using arel (2.0.9)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.12)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3) …Run Code Online (Sandbox Code Playgroud) 我遇到了为ruby 1.9.2安装linecache19(ruby-debug19的依赖项)的问题
这是我的术语输出
$ rvm use 1.9.2
Using /home/bogdan/.rvm/gems/ruby-1.9.2-p180
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
$ rvm exec gem install linecache19 --backtrace
gem install linecache19 --backtrace
rvm 1.6.20 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
ERROR: Error installing linecache19:
linecache19 requires Ruby version >= 1.9.2.
ERROR: Error installing linecache19:
linecache19 requires Ruby version >= 1.9.2.
Building native extensions. This could take a while...
Run Code Online (Sandbox Code Playgroud)
最后一个命令永远挂起,直到被^ C中断.
任何想法如何解决?
我不是在谈论特定的行号,因为我正在阅读具有相同格式但长度不同的多个文件.
说我有这个文本文件:
Something here...
... ... ...
Start #I want this block of text
a b c d e f g
h i j k l m n
End #until this line of the file
something here...
... ... ...
Run Code Online (Sandbox Code Playgroud)
我希望你知道我的意思.我正在考虑迭代文件,然后使用正则表达式搜索,找到"开始"和"结束"的行号,然后使用linecache从开始行读取到结束行.但是如何获得行号?我可以使用什么功能?
我正在使用ipython,我想保存一个在笔记本中定义的类。我可以使用%save和inspect.getsource函数很好地做到这一点,但是我似乎无法获取类的源代码。我快速浏览了一下inspect中的方法,似乎找不到任何可以帮助的方法。有什么建议么?
class A():
def __init__(self):
self.x = 1
%save filename.py inspect.getsource(A)
inspect.getsource(A)
>>> ...
>>> TypeError: <module '__main__'> is a built-in class
Run Code Online (Sandbox Code Playgroud) 我一直想跑bundle install.以下是我输入的一系列命令以及错误消息的相关片段.
bundle update
Run Code Online (Sandbox Code Playgroud)
安装linecache时出错(0.46),Bundler无法继续.在捆绑之前
确保gem install linecache -v '0.46'成功.
gem install linecache -v '0.46'
Run Code Online (Sandbox Code Playgroud)
还不能处理1.9.x.
gem install linecache19
Run Code Online (Sandbox Code Playgroud)
检查vm_core.h ...没有
最后:
gem install linecache19 -- --with-ruby-include=/opt/t/rvm/src/ruby-1.9.3-p194
ERROR: Error installing linecache19:
ERROR: Failed to build gem native extension.
/opt/t/rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb --with-ruby-include=/opt/t/rvm/src/ruby-1.9.3-p194
checking for vm_core.h... yes
checking for version.h... yes
creating Makefile
make
compiling trace_nums.c
In file included from trace_nums.c:21:
/opt/t/rvm/src/ruby-1.9.3-p194/vm_core.h:311:5: error: unknown type name 'rb_event_hook_t'; did you mean 'rb_event_flag_t'?
rb_event_hook_t *event_hooks;
^~~~~~~~~~~~~~~
rb_event_flag_t
/opt/t/rvm/rubies/ruby-2.0.0-p0/include/ruby-2.0.0/ruby/ruby.h:1602:23: note: 'rb_event_flag_t' …Run Code Online (Sandbox Code Playgroud) 在相应的目录中运行"bundle install"时,我得到了以下错误:
An error occurred while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
在尝试运行gem install linecache19 -v '0.5.12'(如上所述)时,我收到以下错误:
nishant@nishant-Inspiron-1545:~/voylla_website$ gem install linecache19 -v '0.5.12'
Building native extensions. This could take a while...
ERROR: Error installing linecache19:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking for vm_core.h... no
/home/nishant/.rvm/gems/ruby-1.9.2-p320/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39: Use RbConfig instead of obsolete and deprecated Config.
checking for vm_core.h... no
*** extconf.rb failed ***
Could …Run Code Online (Sandbox Code Playgroud) 在Python中,我遇到一个问题,每当我使用模块getline()中的函数时linecache,它根本不起作用。假设这是我在名为 的文本文档中得到的内容hi.txt:
Hi
Run Code Online (Sandbox Code Playgroud)
并说这是我在同一文件夹/目录中的 python 程序上的内容:
import linecache
print (linecache.getline("hi.txt", 0))
Run Code Online (Sandbox Code Playgroud)
它不会打印任何内容,只是一些空行。
我有一个奇怪的问题,这是我尝试解释:
我正在创建一个打开txt文件的程序,然后使用以下命令linecache.getline(path,number)读取该文件的一行,在完成该函数后,我使用commmand linecache.clearcache.
如果我然后在文本文件中更改某些内容,则会一直返回预先更改的行.
以下是我正在使用的代码(我知道它真的很漂亮)
def SR(Path,LineNumber):
returns = lc.getline(Path,LineNumber)
x = np.array([])
y = np.array([])
words = returns.split()
for word in words:
x = np.append([x],[word])
for i in range(len(x)):
t = float(x[i])
y = np.append([y],[t])
return y
del x
del y
del t
del words
lc.clearcache()
Run Code Online (Sandbox Code Playgroud)