element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
BeagleBoard
  • Products
  • Dev Tools
  • Single-Board Computers
  • BeagleBoard
  • More
  • Cancel
BeagleBoard
Forum Py-Visa
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join BeagleBoard to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 17 replies
  • Answers 10 answers
  • Subscribers 102 subscribers
  • Views 3821 views
  • Users 0 members are here
Related

Py-Visa

angellxp
angellxp over 6 years ago

Should Py-Visa be usable as is on a BBB?  I'll be attempting to install it tonight.

  • Sign in to reply
  • Cancel

Top Replies

  • mp2100
    mp2100 over 6 years ago in reply to Gough Lui +3 suggested
    The BBB does use apt, not pacman. JonA says he's using "latest" images, so it will be debian, which uses apt. Gough's link to make-use-of has clear instructions for installation and updating, just in case…
  • Gough Lui
    Gough Lui over 6 years ago in reply to angellxp +3 suggested
    I understand what you are saying, but the root of your issue is that your BBB environment doesn't match that of your development PC. By way of analogy, imagine if you wrote a text in English (your Python…
  • Gough Lui
    Gough Lui over 6 years ago +2 suggested
    I suspect it should be usable on most platforms which have access to Python. By default, PyVISA relies on the National Instruments VISA installation if it is available, but can also fallback to using pyvisa…
Parents
  • angellxp
    0 angellxp over 6 years ago

    When I try to load the following into cloud9, I get the following error.  How do I get the dang module to load?

     

    # Import libraries
    import visa
    import os
    import time
    
    
    # Open a VISA resource manager pointing to the installation folder for the Keysight Visa libraries. 
    rm = visa.ResourceManager() 
      
    # ALTER LINE BELOW - Update the VISA resource string to match your specific VNA
    myFF = rm.open_resource("TCPIP0::192.168.7.20::inst0::INSTR") 
    myFF.write(':FORMat:DATA %s,%d' % ('ASCii', 0)) 

     

     

    Traceback (most recent call last):
      File "/var/lib/cloud9/PILOT_Test/FFtransfer.py", line 8, in <module>
        import visa
    ImportError: No module named visa

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Gough Lui
    0 Gough Lui over 6 years ago in reply to angellxp

    This implies your Python installation doesn't have pyvisa installed because it fails in import visa.Try installing it again?

    • pip install -U pyvisa
    • pip install -U pyvisa-py

     

    - Gough

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • angellxp
    0 angellxp over 6 years ago in reply to Gough Lui

    Trying to log in from either the serial connection or the terminal on the BBB desktop, It errors saying pip is not valid/installed

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Gough Lui
    0 Gough Lui over 6 years ago in reply to angellxp

    Then its likely you have a very outdated version of Python. Try updating all the packages on your OS. If not, perhaps you can install pip - https://www.makeuseof.com/tag/install-pip-for-python/

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • angellxp
    0 angellxp over 6 years ago in reply to Gough Lui

    I am typing these commands directly into my BBB...  I am using the latest BBB image to boot from

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Gough Lui
    0 Gough Lui over 6 years ago in reply to angellxp

    The latest image doesn't necessarily mean it has the latest packages installed. Likewise, I don't use BBB at present, but its easier to update packages and install pip as I mentioned above. I don't know but I suspect BBB uses pacman instead of apt.

     

    - Gough

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • mp2100
    0 mp2100 over 6 years ago in reply to Gough Lui

    The BBB does use apt, not pacman.  JonA says he's using "latest" images, so it will be debian, which uses apt.  Gough's link to make-use-of has clear instructions for installation and updating, just in case pip is an old version.

     

    I just did a:

    $ sudo apt-get install python3-pip

     

    on my debian (ubuntu) laptop, and the version command returns this:

     

    t440-ubuntu:~$ pip3 --version

    pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

     

    JonA, did you check/confirm whether you're using python 2 (2.7), or python 3.x?  After the above, I installed python-pip (pip2) and get the following:

    t440-ubuntu:~$ pip --version

    pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • angellxp
    0 angellxp over 6 years ago in reply to mp2100

    Is there a universal command to update all?

     

    image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Gough Lui
    0 Gough Lui over 6 years ago in reply to angellxp

    It looks like you don't have python-pip installed but you do have python3-pip installed. If you're intending to use Python 3, then you can use that.

     

    I didn't realize BBB is Debian based, this makes it veryvsimilarsto the RPi.

     

     

    I'd suggest you do something like:

    sudo apt-get update

    sudo apt-get upgrade

    sudo apt-get install python-pip

     

    Then run the pip commands as listed before to install pyvisa.

     

    - Gough

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • angellxp
    0 angellxp over 6 years ago in reply to Gough Lui

    I personally don't care which python I use.  The code was originally coded in py2.7 apparently as that is what is on my PC.

     

    I just need to get the BBB to load my code and at present it is not loading/recognizing my visa module.

    image

     

    image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Gough Lui
    0 Gough Lui over 6 years ago in reply to angellxp

    You may not care, but the computer might! There are subtle differences in the syntax between Python 2.x and 3.x which means they are not always interchangeable. The most glaring example is print - in 2.x, you could write print 'Hello', whereas 3.x requires print('Hello').

     

    If your code is not impacted by the changes, you could try installing pyvisa on Python 3.x with pip3 rather than pip and run python3 scriptname.py rather than python scriptname.py

     

    Regardless, did you run the commands in the last post that I suggested? That should upgrade all packages and install pip for Python 2.x so you can then run the commands to install pyvisa for Python 2.x as well.

     

    - Gough

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • angellxp
    0 angellxp over 6 years ago in reply to angellxp

    Agreed.  I know there are definitely differences.  What I mean is that I'll code it either way, I just want it to work...  image

     

    It is not the PC I have issues with, the code runs fine on the PC but I cannot get it to load on the BBB.  The visa module is the only error it throws when I try to run/compile it.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • angellxp
    0 angellxp over 6 years ago in reply to angellxp

    Agreed.  I know there are definitely differences.  What I mean is that I'll code it either way, I just want it to work...  image

     

    It is not the PC I have issues with, the code runs fine on the PC but I cannot get it to load on the BBB.  The visa module is the only error it throws when I try to run/compile it.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Gough Lui
    0 Gough Lui over 6 years ago in reply to angellxp

    I understand what you are saying, but the root of your issue is that your BBB environment doesn't match that of your development PC.

     

    By way of analogy, imagine if you wrote a text in English (your Python program that depends on pyvisa) and gave it to a friend next door (a Python interpreter on your PC) to read. As they can understand English (the pyvisa package is installed), this is no problem. Send the same text to a friend (another Python interpreter on your BBB) who is a native Chinese in China (does not have the pyvisa package installed yet) and they won't understand (program won't run as dependency is not met). They need to learn English (install the pyvisa package on the BBB), but in order to do that, they need to go to school (consult a package manager - pip). But their rural town has no school, so they must build one first (install pip from the OS package repository on the BBB).

     

    Your BBB doesn't have pip installed so you can install pyvisa on the BBB. You can't just migrate your python script between environments and expect them to work unless all dependent modules are installed.

     

    So as I said before and I will reiterate - update your packages on the BBB, install python2-pip package to get pip functionality, then use pip to install pyvisa on the BBB. If you get errors doing this, post them as that is the easiest way to help diagnose your issue.

     

    - Gough

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube