python correct way to import packages and how to use them in pycharm console -


i writing pr statsmodels branch , full code available here (https://github.com/statsmodels/statsmodels/pull/2435)

this structure of folder.

donbeo@donbeo-hp-elitebook-folio-9470m:~/documents/statsmodels/statsmodels/sandbox$ tree gam_gsoc2015/ gam_gsoc2015/ ├── draft.py ├── draft.py~ ├── gam_example.py ├── gam_example.py~ ├── gam_example.r ├── gam.py ├── gam.py~ ├── __init__.py ├── __pycache__ │   ├── gam.cpython-34.pyc │   ├── __init__.cpython-34.pyc │   └── smooth_basis.cpython-34.pyc ├── smooth_basis.py └── tests     ├── __init__.py     ├── __pycache__     │   ├── __init__.cpython-34.pyc     │   ├── test_gam.cpython-34.pyc     │   └── test_smooth_basis.cpython-34.pyc     ├── results     │   └── prediction_from_mgcv.csv     ├── test_gam.py     ├── test_gam.py~     ├── test_smooth_basis.py     └── test_smooth_basis.py~  4 directories, 21 files donbeo@do 

both gam_example.py , test_gam.py import functions gam.py

i using pycharm community

i have marked gam_gsoc2015 sources root , able run gam_example or test_gam file pycharm encounter series of problems:

1) gam_gsoc2015 folder 1 in project marked in blue. (i.e. 1 marked sources root)

2) not able run tests nosetest

donbeo@donbeo-hp-elitebook-folio-9470m:~/documents/statsmodels/statsmodels/sandbox$ nosetests ................ee......................................................s................... ====================================================================== error: failure: importerror (no module named 'smooth_basis') ---------------------------------------------------------------------- traceback (most recent call last):   file "/usr/local/lib/python3.4/dist-packages/nose/failure.py", line 39, in runtest     raise self.exc_val.with_traceback(self.tb)   file "/usr/local/lib/python3.4/dist-packages/nose/loader.py", line 414, in loadtestsfromname     addr.filename, addr.module)   file "/usr/local/lib/python3.4/dist-packages/nose/importer.py", line 47, in importfrompath     return self.importfromdir(dir_path, fqname)   file "/usr/local/lib/python3.4/dist-packages/nose/importer.py", line 94, in importfromdir     mod = load_module(part_fqname, fh, filename, desc)   file "/usr/lib/python3.4/imp.py", line 235, in load_module     return load_source(name, filename, file)   file "/usr/lib/python3.4/imp.py", line 171, in load_source     module = methods.load()   file "<frozen importlib._bootstrap>", line 1220, in load   file "<frozen importlib._bootstrap>", line 1200, in _load_unlocked   file "<frozen importlib._bootstrap>", line 1129, in _exec   file "<frozen importlib._bootstrap>", line 1448, in exec_module   file "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed   file "/home/donbeo/documents/statsmodels/statsmodels/sandbox/gam_gsoc2015/tests/test_gam.py", line 1, in <module>     smooth_basis import make_poly_basis, make_bsplines_basis importerror: no module named 'smooth_basis'  ====================================================================== error: failure: importerror (no module named 'smooth_basis') ---------------------------------------------------------------------- traceback (most recent call last):   file "/usr/local/lib/python3.4/dist-packages/nose/failure.py", line 39, in runtest     raise self.exc_val.with_traceback(self.tb)   file "/usr/local/lib/python3.4/dist-packages/nose/loader.py", line 414, in loadtestsfromname     addr.filename, addr.module)   file "/usr/local/lib/python3.4/dist-packages/nose/importer.py", line 47, in importfrompath     return self.importfromdir(dir_path, fqname)   file "/usr/local/lib/python3.4/dist-packages/nose/importer.py", line 94, in importfromdir     mod = load_module(part_fqname, fh, filename, desc)   file "/usr/lib/python3.4/imp.py", line 235, in load_module     return load_source(name, filename, file)   file "/usr/lib/python3.4/imp.py", line 171, in load_source     module = methods.load()   file "<frozen importlib._bootstrap>", line 1220, in load   file "<frozen importlib._bootstrap>", line 1200, in _load_unlocked   file "<frozen importlib._bootstrap>", line 1129, in _exec   file "<frozen importlib._bootstrap>", line 1448, in exec_module   file "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed   file "/home/donbeo/documents/statsmodels/statsmodels/sandbox/gam_gsoc2015/tests/test_smooth_basis.py", line 3, in <module>     smooth_basis import make_poly_basis, make_bsplines_basis importerror: no module named 'smooth_basis'  ---------------------------------------------------------------------- ran 91 tests in 21.727s  failed (skip=1, errors=2) donbeo@donbeo-hp-elitebook-folio-9470m:~/documents/statsmodels/statsmodels/sandbox$  

3) if try run file example gam_example in python console pycharm receive following error

backend tkagg interactive backend. turning interactive mode on. traceback (most recent call last):   file "<input>", line 3, in <module>   file "/home/donbeo/applications/pycharm-community-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import     module = self._system_import(name, *args, **kwargs) importerror: no module named 'smooth_basis' 

i think there wrong in folder structure or doing wrong.

what right way solve?

i know posts suggest relative import path or add folder python path. in way project not portable other system , there nothing other folders in project.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -