Local dependencies requeriments.txt for Bluemix server

时间:2018-06-04 16:48:49

标签: python flask pip ibm-cloud requirements

I want to upload a flask server to bluemix. The structure of my project is something like this

  • Classes
    • functions.py
  • Watson
    • bot.py
  • requirements.txt
  • runtime.txt
  • Procfile
  • manifest.yml

my bot.py has this dependency:

from classes import functions

I have tried to include it in the manifest using things like this:
./classes or ./classes/functions

but I have had no luck, it keeps saying either that module is not found or things like pip.exceptions.InstallationError: Invalid requirement: './classes/functions'

I dont know how to add the dependency

manifest.yml

---
applications:
- name: chatbotstest
  random-route: true
  memory: 256M

Procfile (the file that I use to run the app)

web: python watson/bot.py

when I print my sys.path I get this:

    ['..', '/home/vcap/app/watson', '/home/vcap/deps/0/python/lib/python36.zip', '/home/vcap/deps/0/py
e/vcap/deps/0/python/lib/python3.6/lib-dynload', '/home/vcap/deps/0/python/lib/python3.6/site-packages', '/home/vcap/deps/0/python/lib/python3.6/site-
-py3.6.egg', '/home/vcap/deps/0/python/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg']

I have tried to add the folder parent to my script using

Thanks a lot for your help!!!

2 个答案:

答案 0 :(得分:1)

You don't need to include it into the manifest file. Your entire app directory and its subdirectories are uploaded as part of the push command. Thereafter, it is possible to reference the file as shown.

This imports a file in the current directory:

import myfile

This should work for your functions.py:

from classes import functions

答案 1 :(得分:0)

非常感谢,这终于对我有用了,你指出我的回答给了我解决方案,再次感谢!

public class MainContainer : MonoBehaviour
{
    public GameObject containerElement;


    public void setDataInUI<T>(T m_tabsData) 
        where T : DataA, DataB
    {
        containerElement.setData(m_tabsData);
    }
}


public class DataA
{
    public string title;
    public string picUrl;
}

public class DataB
{
    public string title;
}