0

So I know in windows you can just add the file to the Lib folder and then just add import filename to the python script.

Is it possible to do this on Ubuntu in anyway as I need to import this file to make a project work. Link to file need to access

3
  • just put it in the same folder as well, or anywhere in you classpath Commented Jun 24, 2015 at 15:52
  • So add to the pythonpath variable or classpath. Sorry bit of linux newbie Commented Jun 24, 2015 at 15:55
  • possible duplicate of how to include python modules in linux? Commented Jun 24, 2015 at 17:36

2 Answers 2

3

I toured the github repo for a bit, it should be possible to simply copy CMUTweetTagger.py to your folder where yourapp.py is located (same level) then

import CMUTweetTagger

CMUTweetTagger.runtagger_parse(...)

Alternatively, since ark-tweet-nlp-python is a package (has got __init__.py in it)

You can copy the whole ark-tweet-nlp-python folder into e.g. ark_tweet_nlp_python folder (again same level as your script), e.g. by cloning it

Git clone:

git clone https://github.com/ianozsvald/ark-tweet-nlp-python ark_tweet_nlp_python

Use it as a module:

from ark_tweet_nlp_python import CMUTweetTagger
Sign up to request clarification or add additional context in comments.

Comments

0

You need to:

import sys
print sys.path
sys.path.append('/path/to/lib/dir')
import mylib

Also, if the python script you are trying to import is in a directory, you need to make sure that you have an init.py file in that folder. It can be empty (touch /path/to/lib/dir/__init__.py) before an import will work. You can ls /path/to/lib/dir to see if there is an init.py file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.