Python Forum
import scalalib package doesn't work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
import scalalib package doesn't work
#1
Hi Guys

I would like to use the function sharedvars. I've seen many examples of people using it like that: https://python.hotexamples.com/examples/...mples.html
With the imports:
import scalalib
import scala5
I can't install the Modules with pip so I searched in the Internet for them. I found absolutely nothing about scala5 but i found a github repository for scalalib: https://github.com/artsalliancemedia/scala-tests

I downloaded it but can't get it to work. If I put it in the site-packages folder from Python I can't import it and use it.

Can anyone help me to get either scala5 or scalalib working, so I can use sharedvars. Like some kind of step by step guide on how to install those modules.

Would be very appreciated.
Reply
#2
Neither of those packages are in pypi.org, therefore pip will not work.
You will have to resort to the github accounts and find installation instructions
scalalib can be found in many github repositories (take caution)
same for scala 5
pypi options: https://pypi.org/search/?q=%27scala+5%27
Reply
#3
(Apr-17-2020, 12:03 PM)manu_brighter Wrote: Can anyone help me to get either scala5 or scalalib working, so I can use sharedvars. Like some kind of step by step guide on how to install those modules.
Here is run,it's old so need to use Python 2.6 or 2.7.
Quote:Installation

Python 2.6.x is required Just clone the repo, all requirements are included (see below)
I do this step and get import to work can call scalalib.sharedvars()
I do not do next step which is to run a server on 8080.
# Clone Repo
E:\div_code\scala
λ git clone https://github.com/artsalliancemedia/scala-tests.git
Cloning into 'scala-tests'...
remote: Enumerating objects: 173, done.
Receiving objects:  64% (111/eused 0 (delta 0), pack-reused 173
Receiving objects: 100% (173/173), 203.70 KiB | 0 bytes/s, done.
Resolving deltas: 100% (52/52), done.
Checking connectivity... done.

E:\div_code\scala
λ cd scala-tests\

E:\div_code\scala\scala-tests (master)
λ ls
README.md  scala_monitor.py  scala_tools.py  scalalib/  settings-template.json  test_image.png  webservices/

E:\div_code\scala\scala-tests (master)
λ cd scalalib\

# Now in right folder
E:\div_code\scala\scala-tests\scalalib (master)
λ ls
__init__.py          libtest.sca       scalalib.py   scalaprov.py   test_scripts/  win32_unicode_argv.py
'create pydocs.bat'  sca_publisher.py  scalalink.py  scalatools.py  uni_shlex.py

# Running 2.7 and with pypython for easier discover,can just use python command are the same
E:\div_code\scala\scala-tests\scalalib (master)
λ py -2.7 -m ptpython
>>> import scalalib

>>> svars = scalalib.sharedvars()

>>> print(sharedvars.__doc__)

        A class to wrap Scala shared variables (WSH Objects), so using .Value
        isn't necessary to set/access their values.  Shared variables can be
        accessed as attributes of the resulting object.

        Argument:
            defaults                - A dictionary of default values to return.
        Additional behavior:
            - If attempting to read a variable that doesn't exist, or wasn't
                shared, this returns a default (if given), otherwise None.
            - Will silently drop assignments to variables that weren't shared.
            - The Scala vars continue to be available in the main namespace.
            - This version fixes the bug regarding one-element arrays not
                returning to the Scala Script.
        Notes:
            Use of this object is optional and not required to access Scala's
            shared variables.   However, its use makes it easier to write
            scripts that work at the command prompt as well, since scripts
            won't crash on variable access.

        Example:
            import scalalib
            svars = scalalib.sharedvars()  # a defaults dict can be passed here.
            f = file(svars.filename)       # get value
            svars.result = 15              # set value

>>> type(svars)
<type 'instance'>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  client.get_all_tickers() Doesn't work gerald 2 475 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 1,032 May-30-2022, 03:31 PM
Last Post: bowlofred
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 739 Dec-18-2021, 02:38 AM
Last Post: knight2000
  getting an import statement to work in my program barryjo 1 785 Dec-06-2021, 04:28 PM
Last Post: snippsat
  Class Method to Calculate Age Doesn't Work gdbengo 1 805 Oct-30-2021, 11:20 PM
Last Post: Yoriz
  Unable to import sklearn after installing any package ilango 0 729 Oct-25-2021, 07:03 AM
Last Post: ilango
  Process doesn't work but Thread work ! mr_byte31 4 1,153 Oct-18-2021, 06:29 PM
Last Post: mr_byte31
  Psycopg2 doesn't work with python2 MedianykEugene 3 1,932 Aug-10-2021, 07:00 AM
Last Post: ndc85430
  UART Serial Read & Write to MP3 Player Doesn't Work bill_z 15 3,177 Jul-17-2021, 04:19 PM
Last Post: bill_z
  string function doesn't work in script ClockPillow 3 1,473 Jul-13-2021, 02:47 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020