即使文件在 auto_path 目录中,tcl 也找不到包 [英] tcl can't find package even though file is in auto_path directory

查看:63
本文介绍了即使文件在 auto_path 目录中,tcl 也找不到包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 7 上,tcl 8.6.4.

on windows 7, tcl 8.6.4.

我的 repo.tcl 和 region.tcl 文件都在 c:\sites\vive

My repo.tcl and region.tcl files are both in c:\sites\vive

repo 是一个包:

package provide repo 1.0

namespace eval ::repo {}
namespace eval ::repo::create{}

proc ::repo::create {} {...} ...

region.tcl 想要访问 repo.tcl 中的 procs 所以它看起来像这样:

region.tcl wants access to the procs in repo.tcl so it looks like this:

#source ./repo.tcl <---------old method, want to replace with package require
lappend auto_path [pwd] ;#<--puts c:\sites\vive in the autopath so package can find it.

package require repo 1.0 ;#<--tried this with out version number as well. same result.

::repo::create

...

我总是收到这个错误:

找不到包 repo 1.0

can't find package repo 1.0

这两个站点都建议我使用 lappend auto_pathhttps://unix.stackexchange.com/questions/44992/package-require-xxxx-tcl找不到包 BLT

Both of these sites have suggested I use the lappend auto_path https://unix.stackexchange.com/questions/44992/package-require-xxxx-tcl Can't find package BLT

我做错了什么?谢谢!

推荐答案

您必须使用 pkg_mkIndex

% pkg_mkIndex -verbose [pwd] repo.tcl
successful sourcing of repo.tcl
packages provided were {repo 1.0}
processed repo.tcl
% lappend auto_path [pwd]
C:/Dinesh/Backup/cmder/vendor/msysgit/lib/tcl8.5 C:/Dinesh/Backup/cmder/vendor/msysgit/lib C:/Users/dsivaji/Desktop/delete
%
%
%
% package require repo
1.0

查看手册页 pkg_mkIndex 了解更多信息信息.

Have a look at the man page pkg_mkIndex for more information.

这篇关于即使文件在 auto_path 目录中,tcl 也找不到包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆