Jump to content

Python PIP is failing on the RedBrick


xsherlock

Recommended Posts

Dear,

 

I need apscheduler for my python program (quite useful bit) but pip is falling on the instalation. How do I make it install it.

 

tf@red-brick:~$ pip install apscheduler

Downloading/unpacking apscheduler

  Cannot fetch index base URL https://pypi.python.org/simple/

  Could not find any downloads that satisfy the requirement apscheduler

Cleaning up...

No distributions at all found for apscheduler

Storing debug log for failure in /home/tf/.pip/pip.log

 

TIA

Link zu diesem Kommentar
Share on other sites

It works for me. You will need to run pip as root however:

 

tf@red-brick:~$ sudo pip install apscheduler                                    
Collecting apscheduler                                                          
  Downloading APScheduler-3.0.1-py2.py3-none-any.whl (47kB)                     
    100% |################################| 49kB 535kB/s                        
Collecting six (from apscheduler)                                               
  Downloading six-1.8.0-py2.py3-none-any.whl                                    
Collecting futures (from apscheduler)                                           
  Downloading futures-2.2.0-py2.py3-none-any.whl                                
Requirement already satisfied (use --upgrade to upgrade): pytz in /usr/lib/pytho
n2.7/dist-packages (from apscheduler)                                           
Collecting tzlocal (from apscheduler)                                           
  Downloading tzlocal-1.1.2.zip                                                 
Installing collected packages: tzlocal, futures, six, apscheduler               
  Running setup.py install for tzlocal                                          
                                                                                
                                                                                
                                                                                
Successfully installed apscheduler-3.0.1 futures-2.2.0 six-1.8.0 tzlocal-1.1.2  
tf@red-brick:~$                                                                 

Link zu diesem Kommentar
Share on other sites

Thanks, It was it as well as misconfigured DNS.

 

but still no success in running the very same software that works fine on same setup when launched from the PC.

 

2015-01-02T18:09:40.316286+0100

-------------------------------------------------------------------------------

Traceback (most recent call last):

  File "Power logger.py", line 20, in <module>

    from apscheduler.schedulers.background import BackgroundScheduler

ImportError: No module named apscheduler.schedulers.background

 

What else could that be? It works in the win7 PC.

#!/usr/bin/env python
# -*- coding: utf-8 -*-  

HOST = "172.16.0.39"
PORT = 4223
UID_lcd = "o73" # Change to your UID
UID_poti = "fwV"
UID_dual_button = "mEa"
UID_dual_relay = "kDz"
UID_voltage = "nNc"
UID_step = "6RsbXm"
UID_temp = "qnM"
UID_nfc = "oEh"

import binascii
import time
import datetime
from datetime import datetime

from apscheduler.schedulers.background import BackgroundScheduler

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_lcd_20x4 import LCD20x4
from tinkerforge.bricklet_linear_poti import LinearPoti
from tinkerforge.bricklet_dual_button import DualButton
from tinkerforge.bricklet_dual_relay import DualRelay
from tinkerforge.bricklet_voltage_current import VoltageCurrent
from tinkerforge.brick_stepper import Stepper
from tinkerforge.bricklet_temperature import Temperature
from tinkerforge.bricklet_nfc_rfid import NFCRFID

global running_time
running_time=0

def cb_current(current):
    lcd.write_line(1, 0, str(round(current/1000.0,2)) + 'A ')
    voltage = vc.get_voltage()
    lcd.write_line(1, 14, str(round((voltage * current)/1000000.0,2)) + 'W ')

def cb_voltage(voltage):
    lcd.write_line(1, 7, str(round(voltage/1000.0,2)) + 'V ')
    current = vc.get_current()
    lcd.write_line(1, 14, str(round((voltage * current)/1000000.0,2)) + 'W ')

def cb_pressed(i):
    if i==0:
        # datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        log_started = datetime.now().time()
        lcd.write_line(2, 0, 'Logging '  + datetime.now().strftime('%H:%M:%S'))
        
        
        sched.add_job(job_function, 'interval', seconds=1)
        global running_time
        running_time=0
    if i==3:
        lcd.write_line(2, 0, 'Stopped                ' )
        time.sleep(2)
        lcd.write_line(2, 0, '                     ' )
        sched.remove_all_jobs()

def job_function():
    voltage = vc.get_voltage()
    current = vc.get_current()
    global running_time
    print(str(running_time+1)+','+datetime.now().strftime('%H:%M:%S') + ',' + str(round(voltage/1000.0,2)) + ',' + str(round(current/1000.0,2)) + ',' + str(round((voltage * current)/1000000.0,2)))
    
    running_time=running_time+1
       

if __name__ == "__main__":
    ipcon = IPConnection() # Create IP connection
    lcd = LCD20x4(UID_lcd, ipcon) # Create device object
    poti = LinearPoti(UID_poti, ipcon)
    db = DualButton(UID_dual_button, ipcon) # Create device object
    dr = DualRelay(UID_dual_relay, ipcon)
    vc = VoltageCurrent(UID_voltage, ipcon)
    stepper = Stepper(UID_step, ipcon)
    t = Temperature(UID_temp, ipcon)
    nfc = NFCRFID(UID_nfc, ipcon)
    ipcon.connect(HOST, PORT) # Connect to brickd Don't use device before ipcon is connected
    
    sched = BackgroundScheduler()
    sched.start()
    
    
    lcd.backlight_on()# Turn backlight on     # Write "Hello World"
    lcd.register_callback(lcd.CALLBACK_BUTTON_PRESSED, cb_pressed)
  
    
    vc.set_current_callback_period(1000)
    vc.register_callback(vc.CALLBACK_CURRENT, cb_current)
    vc.set_voltage_callback_period(1000)
    vc.register_callback(vc.CALLBACK_VOLTAGE, cb_voltage)
    current = vc.get_current()
    voltage = vc.get_voltage()
    
    lcd.clear_display()
    lcd.write_line(0, 0, 'Curr   Volt   Power  ')
    lcd.write_line(1, 0, str(round(current/1000.0,2)) + 'A ')
    lcd.write_line(1, 7, str(round(voltage/1000.0,2)) + 'V ')
    lcd.write_line(1, 14, str(round((voltage * current)/1000000.0,2)) + 'W ')
    lcd.write_line(3, 0, 'Start           Stop')  
    
    input('Press key to exit\n') # Use input() in Python 3

    ipcon.disconnect()

 

Link zu diesem Kommentar
Share on other sites

Indeed when running the import from the python shell I also dont see the error. Just the software will not run if uploaded with the BrickV

 

If I ssh into the brick and run it manualy in the terminal it will start fine. but then it will crash when i start a tread (with the scheduler)

 

It looks  that it half-works on the pytnon 2.7.3 but not on the 3.2.3

and my development PC has version 3.4.1. Is there a way to upgrade the python verison on the brick.

Link zu diesem Kommentar
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...