简体   繁体   English

Python脚本在Mac上无法在Ubuntu上运行

[英]Python script works on Mac not on Ubuntu

I have a python script that works on Mac and not on Ubuntu. 我有一个在Mac上而不是Ubuntu上运行的python脚本。 When I run it in Ubuntu, I get the following error: 在Ubuntu中运行它时,出现以下错误:

Traceback (most recent call last):
  File "deploy.py", line 15, in <module>
    from modules.ima_python_utils import *
ImportError: No module named modules.ima_python_utils

It works on Mac, I don't know what's wrong. 它可以在Mac上运行,我不知道怎么了。

Ubuntu python version Ubuntu Python版本

python 2.7.3 python 2.7.3

Mac python version Mac python版本

python 2.7.10 python 2.7.10

Here's my structure: 这是我的结构:

  • modules 模组
    • ima_python_utils ima_python_utils
      • __init__.py
      • copy.py 复制
      • ... ...
  • deploy.py deploy.py

deploy.py deploy.py

import sys
import getopt
import os
import parser
import distutils.dir_util
import json
import subprocess
import ConfigParser

from modules.ima_python_utils import *

__init__.py

__all__ = ["copy", "file", "folder", "database"]

I needed to have an __init__.py inside the modules folder as well. 我还需要在modules文件夹中有一个__init__.py I don't know why it was working on OS X but who knows. 我不知道为什么它可以在OS X上运行,但是谁知道呢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Ubuntu,Windows和MAC上运行Python脚本 - How to run Python script on Ubuntu, Windows and MAC Python应用程序在Ubuntu(远程)上被“杀死”,但在Mac(本地)上运行 - Python App is getting “Killed” on Ubuntu (remote), but works on Mac (Locally) 适用于 OSX 和 raspbian 的蛋白质数据库的 Python 脚本在 Ubuntu 中不起作用 - Python script for protein databases that works in OSX and raspbian is not working in Ubuntu Python脚本在Windows上不起作用(但适用于mac) - Python script doesn't work on Windows (but works on mac) 在输入中查找十六进制字符串在 mac 中读取 python3 工作,在 ubuntu 中失败 - find hex string in input read python3 in mac works, in ubuntu fails Ubuntu ImportError:无法导入设置(在Mac上可用) - Ubuntu ImportError: Could not import settings (works on Mac) Ubuntu-链接到Python脚本的.desktop文件-脚本有效,但记录不起作用 - Ubuntu - .desktop file linked to Python script - script works but logging doesn't 在 Ubuntu 上自动启动 python 脚本 - Autostarting a python script on Ubuntu Python脚本作为ubuntu中的守护进程 - Python script as daemon in ubuntu LaTeX 和 Python 适用于 Ubuntu 但不适用于 ZAEA23489CE3AACDB63406EBB28EZ - LaTeX and Python works on Ubuntu but not on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM