Python Forum

Full Version: How to import dependencies from a different directory?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am a php developer and new to python. I am trying to create a custom script for an existing application and not sure how to do it.

this is the application https://github.com/jookies/jasmin and I am trying to run this script https://gist.github.com/farirat/efc604070f34ef699c8b

Do I have to put this inside the application directory or I can run from a different directory and include some kind of file similar to php autoload?

Any help greatly appreciated!

Thank you
You could use [icode] pip install jasmine {/code], with a few things to keep in mind. According to their PyPi page (https://pypi.python.org/pypi/jasmin/0.9.26, they are only compatible with Python v2 and are focused on POSIX OS's (think Unix), though Linux and Mac's are almost POSIX compliant, they are not 100%. If using Windows, you would need something like Cygwin or Windows Subsystem For Linux.

If you follow the installation instructions (http://docs.jasminsms.com/en/latest/inst...index.html, you should be able to run your script from where ever you want, well, within reason, of course, as pip will install it in your Python v2 site-packages.
If you want to keep it in another directory that's OK, but you will need to tell python where is is.
see post 7 here: https://python-forum.io/Thread-Can-t-imp...9#pid39169
@sparkz_alot

Thank you very much for the detailed explanation, I am on linux ubuntu and will give it a try.

I am not much familiar with python version differences, will try to understand better.


@Larz60+
Thank you very much for the example, very helpful to learn a new language.

Cheers!

P.S. I am very surprised with this python forum, very active and fast response. Definitely helpful to newbies.