【问题标题】:Using a symlinked module on Windows with Python在 Windows 上通过 Python 使用符号链接模块
【发布时间】:2011-07-29 01:35:38
【问题描述】:

目前我有一个我想要的 python 模块的符号链接目录与我的文件在同一目录中,但是当我的 python 脚本尝试import pyamf时,python 会引发ImportError: No module named pyamf

复制目录时它工作正常,所以它与符号链接有关(它是用 windows 的 mklink 命令而不是 msys ln 创建的)

Python 是 2.7.2 x64 版本

【问题讨论】:

  • 你是如何运行脚本的?你是从哪个目录开始的?
  • 我不能在这个上直接与 Python 对话,但我知道 PHP 不会将它们识别为实际目录。尽管 Windows 声称它们应该以相同的方式工作,但事实并非如此。
  • 我从标准的 Windows 命令提示符运行它,从与脚本相同的目录和模块存储在。例如只是python script.py
  • mklink 不创建链接。它需要选项和两个参数。如果你不告诉我们问题是什么,我们只能猜测......

标签: python windows windows-7 symlink ntfs


【解决方案1】:

Python 2.7 在 Windows 符号链接方面存在问题。不要创建符号链接,而是使用 \J 选项创建目录连接。例如:

mklink \J link_dir target_dir

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-01
    • 2010-11-29
    • 2014-11-22
    相关资源
    最近更新 更多