ChristianTremblay / pyhaystack

Pyhaystack is a module that allow python programs to connect to a haystack server project-haystack.org. Connection can be established with Niagara Platform running the nhaystack, Skyspark and Widesky. For this to work with Anaconda IPython Notebook in Windows, be sure to use "python setup.py install" using the Anaconda Command Prompt in Windows. If not, module will be installed for System path python but won't work in the environment of Anaconda IPython Notebook. You will need hszinc 1.3+ for this to work.
Apache License 2.0
74 stars 32 forks source link

AttributeError for SkySpark #50

Closed p2ya closed 7 years ago

p2ya commented 7 years ago

Hi, I recently started using Pyhaystack for Skyspark connection by:

import hszinc from pyhaystack.client.skyspark import SkysparkHaystackSession session = SkysparkHaystackSession(uri='http://ip', username='username', password='password', project='project', grid_format=hszinc.MODE_JSON )

As suggested on closed issue #14

I also tried what was on http://pyhaystack.readthedocs.io/en/latest/connect.html#skyspark: However, I get the following error:

expect_format=hszinc.MODE_ZINC, multi_grid=False,

AttributeError: 'module' object has no attribute 'MODE_ZINC'

Any idea why this happens and how to resolve it ?

sjlongland commented 7 years ago

On 15/05/17 11:07, p2ya wrote:

I also tried what was on http://pyhaystack.readthedocs.io/en/latest/connect.html#skyspark: However, I get the following error:

|expect_format=hszinc.MODE_ZINC, multi_grid=False, |

AttributeError: 'module' object has no attribute 'MODE_ZINC'

Any idea why this happens and how to resolve it ?

That to me, suggests something is broken with the installation of hszinc. How did you install everything? -- Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind... ...it's backed up on a tape somewhere.

p2ya commented 7 years ago

pip install hszinc

ChristianTremblay commented 7 years ago

Does it work if you don't specify the format ?

Also, if using version 0.92 (latest), can you test using

''' Import pyhaystack session=pyhaystack.connect("skyspark", uri, user,password) '''

We may face something related to authentication. The class you are loading isn't meant for Skyspark v3+

Using connect, when specifying "skyspark" the default implementation will use scram authentication.

p2ya commented 7 years ago

No, it doesn't.

Checked versions:

pip show pyhaystack

Name: pyhaystack Version: 0.92 Location: /usr/local/lib/python2.7/site-packages Requires: requests, setuptools, pandas, parsimonious, iso8601, hszinc, six, fysom, signalslot, semver

pip show hszinc

Name: hszinc Version: 0.1.1 Location: /usr/local/lib/python2.7/site-packages Requires: parsimonious, pytz, iso8601, six, pint

Also when I tried the connect() approach I got the following error:

Code: import pyhaystack session = pyhaystack.connect(implementation='skyspark', uri='http://ip', username='username', password='password', project='site' )

Error:

session = pyhaystack.connect(implementation='skyspark', AttributeError: 'module' object has no attribute 'connect'

p2ya commented 7 years ago

I am testing that on SkySpark version 2.1.15

ChristianTremblay commented 7 years ago

Humm... AttributeError: 'module' object has no attribute 'connect'is telling me there is a problem with the install..

Can you uninstall pyhaystack and hszinc then reinstall ? I've faced that kind of problem before but I thought it was because I was alterning between a local repo and pip install.... anyway.

pip uninstall pyhsyatck (multiple time until there is no version left on your system) pip uninstall hszinc (mutliple time again if needed)

then pip install pyhaytsack it should install hszinc

p2ya commented 7 years ago

did the uninstall and installed pyhaystack but it has the same errors for both direct and connect approach

ronaldsnyder commented 7 years ago

Did you install using sudo? May need to install using virtualenv

On May 15, 2017 10:05 PM, "p2ya" notifications@github.com wrote:

did the uninstall and installed pyhaystack but it has the same errors for both direct and connect approach

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChristianTremblay/pyhaystack/issues/50#issuecomment-301654596, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSJ-ftu23zKdw3KqiJMumEt0T49N6k5ks5r6QRfgaJpZM4NakdI .

p2ya commented 7 years ago

tried the sudo and same error

p2ya commented 7 years ago

is there any chance that you test it for SkySpark and see if it work ?

sjlongland commented 7 years ago

I personally don't have access to SkySpark… but my hunch is there's a dependent Python module (of hszinc) that isn't loading for some reason.

That is why there's an AttributeError.

ronaldsnyder commented 7 years ago

Are you using a Mac? This sounds similar to issue 34, https://github.com/ChristianTremblay/pyhaystack/issues/34

These are the steps that @ChristianTremblay gave me before that fixed it.

It is probably related to some kind of permission of the "system's python" version. To be able to make it work, you will need to use a virtual env that will isolate you from the system's python. Here is a simple guide : http://docs.python-guide.org/en/latest/dev/virtualenvs/ You will need to :

sudo pip install virtualenv mkdir your project folder cd project virtualenv venv source venv/bin/activate

Once you are in your virtual env DO NOT use sudo to pip install. (in fact, this is the part that made me think of permission issue as I read somewhere that we should never sudo pip install anything)

So now you are in your virtual env (it's in parenthesis in the console) and you

pip install requests pip install hszinc pip install pyhaystack (note that this time you won't see any weird message when trying to install pandas and you need xcode to perform the install....) You are now able to :

import hszinc hszinc.MODE_ZINC

from pyhaystack.client.skyspark import SkysparkHaystackSession

ChristianTremblay commented 7 years ago

I've also had some problem with pip unable to uninstall things... you could also check to update pip : python -m pip install --upgrade pip Then uninstall pyhaystack the attribute erroris not normal as it tells that function connect doesn't exist...

I've just tested a Skyspark v2 connection :

import pyhaystack

session = pyhaystack.connect('skyspark2', uri='http://ip',
                                username='user',
                                password='pw',
                                project = 'myProject')

session.about().result

Please note that implementation for old Skyspark version is skyspark2 and we chose 'skyspark`as the shortcut for v3+ which will probably become the "by default" option anyway.

This also led to a bug discovered with bracket search... guess I'll open an issue and publish a hot fix....

p2ya commented 7 years ago

Hi Ron Worked like a charm, thanks for the help. I will carry on using the package.

ChristianTremblay commented 7 years ago

I will add this to our documentation. It will probably help others. Thanks @ronaldsnyder

ChristianTremblay commented 7 years ago

Documentation has been updated in develop branch