Python脚本快捷方式无法在Windows中导入某些模块

时间:2016-07-19 19:31:16

标签: python windows import call importerror

我处理了这个问题的几个帖子,我不小心意外地解决了#34;问题,但可以预见它已经重新浮出水面。我需要通过单击它来使我的Python脚本可执行。我已经阅读了How to execute Python scripts in Windows?中发布的信息;但我遇到一个问题,其中用户使用快捷方式执行的scriptA调用scriptB,然后无法导入用户安装的模块。当我执行它时,这个程序完全正常:

python scriptA.py

但是,通过单击调用scriptA并让它调用scriptB的组合给出了scriptB导入错误,否则不会发生。认为这是一个路径问题,我尝试尽可能多地添加路径到PATH和PYTHONPATH,这只是给出了一个不同但相关的导入错误。

在scriptA中我有

from Tkinter import *
from subprocess import call
import numpy

# some code 
call(["python", "levMap12.py", inputFilePath, outputFilePath, LVscalingFactor, corrFilePath, corrScalingFactor])

在scriptB中我有

import math
import Levenshtein as LV
import csv
import openpyxl
import sys
import pickle

# some code 

文件路径:

PATH
C:Python27;C:Python27\Scripts;C:Python27\Lib;C:Python26;C:\Python26\Scripts;C:\Python26\Lib;C:\python-Levenshtein-0.12.0\Levenshtein;C:\Python26\Lib;C:\python-Levenshtein-0.12.0;C:\Program Files\7-Zip\

PYTHONPATH
C:\python-Levenshtein-0.12.0\Levenshtein;C:\python-Levenshtein-0.12.0

完全引用:

Traceback (most recent call last):
  File "levMap12.py", line 3, in <module>
    import Levenshtein as LV
  File "C:\python-Levenshtein-0.12.0\Levenshtein\__init__.py", line 1, in <module>
    from Levenshtein import _levenshtein
ImportError: cannot import name _levenshtein

当我只需双击scriptA.py文件时就会发生此错误。但是,当我尝试通过选择使用python.exe打开来执行该文件时,我收到另一个错误

python: can't open file 'levMap12.py': [Errno 2] No such file or directory

我已启用设置为所有.py文件使用python.exe并将.PY添加到PATHTEXT系统变量

此外,如果它有任何相关性,我使用的是Windows 8和Python 2.7

0 个答案:

没有答案
相关问题