Spyder -- sys.path doesn't work fine

45 views
Skip to first unread message

Laurent Desmet

unread,
May 8, 2018, 9:17:53 PM5/8/18
to spyder
Hi everyone,

I want to try to import a .py,  "Usefull function.py", which contain some function I want to apply. The thing is, this file is located from another folder. Here is my code :


from __future__ import print_function

import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import RMSprop
from matplotlib.patches import Rectangle
import timeit
import numpy as np
from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
import sys
sys.path.insert(0, 'C:/Users/Laurent/Desktop/travail EPM')
from Usefull_function import *

Basically I have this output :

ModuleNotFoundError: No module named 'Usefull_function'


I don't get why, I can guarantee the file "Usefull function.py" is in this folder  'C:/Users/Laurent/Desktop/travail EPM' but for a resaon, doesn't find it.
By the way, when I click on "run" the explorer always returns to the folder where the file I'm running.

If someone could help me, I would be very gratefull !

Thank's everyone !

J D

unread,
May 19, 2018, 7:56:21 PM5/19/18
to spyder
workaround is to use sys.path.append

thanks
Jay
Reply all
Reply to author
Forward
0 new messages