lczub / TestLink-API-Python-client

A Python client to use the TestLink API
105 stars 63 forks source link

Cannot import name TestlinkAPIClient #31

Closed nitrocode closed 9 years ago

nitrocode commented 9 years ago

I downloaded the latest version of pip for Python 2.7 Installed using the pip command successfully I set the TESTLINK environment variables

Set TESTLINK_API_PYTHON_SERVER_URL=etc
Set TESTLINK_API_PYTHON_DEVKEY=etc

Opened Python and ran

import testlink

and I received an import error

ImportError: cannot import name TestlinkAPIClient

I also tried running some of the example scripts but also received errors.

I navigated to /usr/local/lib/python2.7/dist-packages/testlink where the module was installed and attempted to run some of the code within the scripts:

from testlinkapigeneric import TestlinkAPIGeneric, TestLinkHelper

Traceback (most recent call last): File "", line 1, in File "testlinkapigeneric.py", line 22, in from .testlinkhelper import TestLinkHelper, VERSION ValueError: Attempted relative import in non-package

Not sure what I'm doing wrong...

nitrocode commented 9 years ago

Nevermind. Somehow when I ran the example script it created a .pyc file in my homefolder and kept trying to run that. I removed the .pyc file and I was able to import testlink correctly. Also do not try to import a module from the directory of the package. You will get the "Attempted relative import in non-package" error.

Also realized that the set commands did not work. What did work was the following:

import testlink
TESTLINK_API_PYTHON_SERVER_URL="https://testlink/etc/etc/etc"
TESTLINK_API_PYTHON_DEVKEY="someapikey"

tls = testlink.TestLinkHelper( TESTLINK_API_PYTHON_SERVER_URL, TESTLINK_API_PYTHON_DEVKEY ).connect(testlink.TestlinkAPIClient)
print tls.countProjects()
tc_info = tls.getTestCase(None, testcaseexternalid='S-10000')
print tc_info
print tls.whatArgs('createTestPlan')

Thank you for the API

lczub commented 9 years ago

Hello nitrocode,

I'm sorry, I could not reproduce your failure situation with my debian installation.

It looks like a general problem with your python environment. Have you tried to install other packages from https://pypi.python.org/pypi ?

Tipp: It's always a good idea, not to install such additional packages directly into your main python installation. Better approach is to setup a "virtual python" installations via virtualenv. More infos see https://virtualenv.pypa.io/en/latest/virtualenv.html

Hope this helps a little bit. Luiko