Python Forum
How to import dependencies from a different directory?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to import dependencies from a different directory?
#1
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
Reply
#2
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 it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
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
Reply
#4
@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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to see dependencies before installing a package? quazirfan 4 1,056 Dec-06-2022, 02:50 PM
Last Post: snippsat
  How to import another Python in different directory? dee 3 879 Sep-28-2022, 06:41 PM
Last Post: dee
  Managing dependencies with pipenv t4keheart 6 2,922 Aug-05-2020, 12:39 AM
Last Post: t4keheart
  Python 2.7 Import error. Directory and filename conflict petcoo00 2 2,368 Feb-02-2020, 08:46 PM
Last Post: snippsat
  Easier way to manage dependencies? Tylersuard 2 2,350 Jan-01-2020, 09:19 PM
Last Post: Tylersuard
  Missing required dependencies when using pyinstaller Ghonim 15 23,318 Jul-15-2019, 08:47 AM
Last Post: shubhthkr
  How to import a file from outside the directory sylas 5 6,676 May-10-2018, 07:19 AM
Last Post: Larz60+
  How to find the list of dependencies not present in the remote artifactory repository csplrj 6 4,682 Mar-30-2018, 03:43 PM
Last Post: csplrj

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020