python different import behaviour on osx and ubuntu
NickName:Donbeo Ask DateTime:2016-04-06T00:36:40

python different import behaviour on osx and ubuntu

I have the same python project on 2 computers running osx and ubuntu 14.04

I am running a script in the phd_thesis.non_linear_features_selection folder At the beginning of the script I import some functions as:

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

I have to use a different import path on osx and ubuntu. Why is this happening? How can I have a single import that works on both os?

EDIT: The project is a bit messy. Here the tree structure:

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

The script that I am running is |-- polynomial_data_example.py (6th element from the bottom)

Copyright Notice:Content Author:「Donbeo」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36432203/python-different-import-behaviour-on-osx-and-ubuntu

More about “python different import behaviour on osx and ubuntu” related questions

python different import behaviour on osx and ubuntu

I have the same python project on 2 computers running osx and ubuntu 14.04 I am running a script in the phd_thesis.non_linear_features_selection folder At the beginning of the script I import some

Show Detail

Different behaviour of os.writev on Ubuntu and Mac

I have experienced some difficulties with function os.writev in Python3.5 when used on mac. On Linux (Ubuntu) everything works as expected but when I pass empty list on mac: os.writev(descriptor, ...

Show Detail

Different behavior of numpy transpose() with Ubuntu vs OSX

I'm running the following code on two different machines: import pandas as pd import numpy as np # compute ids coeff = np.dot(matrix1, np.transpose(matrix2)) where matrix2 is a pandas dataframe...

Show Detail

Deploying Python application+dependencies on OSX from Ubuntu

Background: I'm writing a non-commercial application in Python, that uses wxPython, and depends on pyPortMidi and SciPy (both available on PyPi). I would like to share this with a small circle of ...

Show Detail

Python multiprocessing copy-on-write behaving differently between OSX and Ubuntu

I'm trying to share objects between the parent and child process in Python. To play around with the idea, I've created a simple Python script: from multiprocessing import Process from os import ge...

Show Detail

Python open() unicode filename behaviour different across OSes

With a filename looking like: filename = u"/direc/tories/español.jpg" And using open() as: fp = open(filename, "rb") This will correctly open the file on OSX (10.7), but on Ubuntu 11.04 the ope.

Show Detail

Different behaviour for circular import in submodules of package

I am writing a Python package and I am observing different behaviour for circular imports depending on whether I use from x import y or import x.y in the submodules within the package. To be clear...

Show Detail

python igraph import error on Ubuntu 16.04

I recently upgraded Ubuntu from 14.04 to 16.04 and I have strange issues with using python igraph (on anaconda). I didn't have any issues in the 14.04. Specifically - pip install python-igraph see...

Show Detail

Cannot import Bluetooth in Python 3 (OSX)

I reinstalled PyBluez some weeks ago since I couldn't get basic functions to work. Now I can't even import it to Python 3. import bluetooth Traceback (most recent call last): File "<pyshell#0&g...

Show Detail

Python _ctypes import error on OSX 10.6

I'm very new to Python development, and am having a problem with one of my apps in OSX. Technologies being used in this project python 2.6 django google app engine rpx (openid) When loading up the

Show Detail