python在osx和ubuntu上的不同导入行为
我在运行osx和ubuntu 14.04的两台计算机上有相同的python项目 我正在python在osx和ubuntu上的不同导入行为,python,macos,ubuntu,import,Python,Macos,Ubuntu,Import,我在运行osx和ubuntu 14.04的两台计算机上有相同的python项目 我正在博士论文.非线性特征选择文件夹中运行脚本 在脚本的开头,我导入了一些函数,如下所示: import numpy as np #from phd_thesis.non_linear_features_selection.example_datasets.polynomial_datasets import * # it works only on OSX
博士论文.非线性特征选择
文件夹中运行脚本
在脚本的开头,我导入了一些函数,如下所示:
import numpy as np
#from phd_thesis.non_linear_features_selection.example_datasets.polynomial_datasets import * # it works only on OSX
from example_datasets.polynomial_datasets import * # it works only on ubuntu
我必须在osx和ubuntu上使用不同的导入路径。为什么会这样?如何使一个导入在两个操作系统上都工作
编辑:这个项目有点乱。这里是树结构:
onbeo@donbeo-OptiPlex-790:~/Dropbox/pythoncode/phd_thesis/non_linear_features_selection$ tree
.
|-- checkpoint
|-- deep_learning
| |-- autoencoder_fsca.py
| |-- autoencoder_fsca.py~
| |-- autoencoder_j2m.py
| |-- autoencoder_j2m.py~
| |-- autoencoder_magic.ckpt
| |-- autoencoder_NC60.ckpt
| |-- autoencoder_parkinson.ckpt
| |-- checkpoint
| |-- mnist_autoencoder.ckpt
| |-- nn_j2m.py
| |-- nn_j2m.py~
| |-- nn_selector_magic_nino.py
| |-- nn_selector_magic_nino.py~
| `-- results
|-- elm_fsca_j2m.py
|-- elm_fsca_j2m.py~
|-- elm_fsca_poly_example.py
|-- elm_fsca_poly_example.py~
|-- elm_fsca_various_datasets.py
|-- elm_fsca_various_datasets.py~
|-- example_datasets
| |-- __init__.py
| |-- polynomial_datasets.py
| |-- polynomial_datasets.py~
| `-- __pycache__
| |-- __init__.cpython-34.pyc
| `-- polynomial_datasets.cpython-34.pyc
|-- examples_issc2016.py
|-- examples_issc2016.py~
|-- __init__.py
|-- j2m_results_plot.py
|-- j2m_results_plot.py~
|-- neural_network_lasso.py
|-- neural_network_lasso.py~
|-- non_linear_regression_examples_plot.py
|-- non_linear_regression_examples_plot.py~
|-- non_linear_regression_examples.py
|-- non_linear_regression_examples.py~
|-- non_linear_regression_simulated_data_tables.py
|-- non_linear_regression_simulated_data_tables.py~
|-- parity_function_example.py
|-- parity_function_example.py~
|-- polynomial_data_example.py
|-- polynomial_data_example.py~
|-- __pycache__
| `-- __init__.cpython-34.pyc
|-- real_data_example.py
`-- results
我正在运行的脚本是
|--polymonal\u data\u example.py
(从底部开始的第六个元素)您的项目结构如何?我的观点,而不是你问题的答案:你不应该使用import*
你在examle\u数据集和多项式\u数据集中有init.py文件吗?我已经包括了项目树的一部分。ubuntu的第二次导入是正确的导入。它也应该适用于OSX、windows和linux。但是,你可以试试。在init.py的示例_数据集下:from.polymonery_数据集import*
。在脚本中:来自示例数据集导入*
。如果它不起作用,你能发布错误消息吗!检查是否有任何文件未在OSX上正确同步。Dropbox可能有错误消息/冲突,因此它没有在OSX上创建本地版本,或者本地版本不正确/损坏。