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

Droid_Interceptor
  • 613
  • 3
  • 14
  • 37

2 Answers2

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
bakkal
  • 54,350
  • 12
  • 131
  • 107
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.

mikeb
  • 10,578
  • 7
  • 62
  • 120