Go to advanced search

by robbes
Wed Mar 20, 2019 4:41 pm
Forum: Python
Topic: How to use command terminal code in Python program?
Replies: 3
Views: 264

Re: How to use command terminal code in Python program?

The plumbum library might be convenient for your use case:
https://plumbum.readthedocs.io/en/latest/
by robbes
Mon Mar 04, 2019 5:39 pm
Forum: Python
Topic: Problem upgrading - broken Python installation
Replies: 3
Views: 278

Re: Problem upgrading - broken Python installation

You could try running

Code: Select all

dpkg --audit python
and

Code: Select all

dpkg --verify python
for suggestions, before doing --remove or --purge and reinstalling
by robbes
Wed Feb 20, 2019 7:18 pm
Forum: Python
Topic: Using python scripts in html / javascript
Replies: 4
Views: 410

Re: Using python scripts in html / javascript

How about a pure python webapp using PySimpleGUIWeb or remi ?
by robbes
Thu Jan 24, 2019 9:58 pm
Forum: Python
Topic: My Python is stuck
Replies: 6
Views: 543

Re: My Python is stuck

I was not expecting the binary to be installed in that location (my ignorance!) but you don't have to "do" anything other than invoking python with $ /home/pi/Python-2.7.9/python Assuming pip was installed with this package, you would install flask-ask with /home/pi/Python-2.7.9/python -m pip instal...
by robbes
Thu Jan 24, 2019 6:55 pm
Forum: Python
Topic: My Python is stuck
Replies: 6
Views: 543

Re: My Python is stuck

As you have already recognized, the issue has nothing to do with your hardware. On your production machine, if you enter

Code: Select all

$ python --version
then I imagine you will see python 2.7.3.
Can you not just use

Code: Select all

$ python2.7.9
and

Code: Select all

$ python2.7.9 - m pip
instead?
by robbes
Wed Dec 12, 2018 2:24 am
Forum: Python
Topic: Upgrade Python from 3.5.3 to latest version
Replies: 15
Views: 24397

Re: Upgrade Python from 3.5.3 to latest version

On my not-quite-updated Raspberry Pi, installed python3.5 packages are at /usr/lib/python3.5/dist-packages/ if installed by apt, and at /usr/local/lib/python3.5/dist-packages/ if installed by pip. If you run >>> import site >>> site.getsitepackages() then you should get a list of all the package ins...
by robbes
Tue Dec 11, 2018 9:18 pm
Forum: Python
Topic: Upgrade Python from 3.5.3 to latest version
Replies: 15
Views: 24397

Re: Upgrade Python from 3.5.3 to latest version

I don't think your code

Code: Select all

(venv) [email protected]:~/projects/venv $ sudo apt-get install python3-smbus
is acting as you want.
You can run apt-get from anywhere (including from a python virtual environment) and it will still perform a global install.
Have you tried the system-site-packages flag?
by robbes
Tue Dec 11, 2018 6:28 pm
Forum: Python
Topic: Upgrade Python from 3.5.3 to latest version
Replies: 15
Views: 24397

Re: Upgrade Python from 3.5.3 to latest version

and when I try to import smbus I get a module not found error It seems you have installed python3-smbus globally and do not have access to it inside your virtual environment. Try setting up your environment using the system-site-packages flag: python3 -m venv <your_env_name> --system-site-packages
by robbes
Mon Oct 22, 2018 4:54 pm
Forum: General discussion
Topic: How build an app run some web server, web app?
Replies: 1
Views: 308

Re: How build an app run some web server, web app?

systemd should do that. Google "systemd user services".
by robbes
Tue Sep 11, 2018 3:57 pm
Forum: Python
Topic: importing modules from other directory paths
Replies: 9
Views: 1038

Re: importing modules from other directory paths

What is in your variable PYTHONPATH?
Have you made PYTHONPATH available to the python interpreter through an export statement? sys.path won't be able to access it otherwise.
by robbes
Sun Aug 26, 2018 4:00 am
Forum: Python
Topic: How to deliver variable to a function in another file which then uses the variable value
Replies: 2
Views: 427

Re: How to deliver variable to a function in another file which then uses the variable value

It isn't possible to access a variable name directly in python - the name is a mapping, not an object. You could create a string with the same variable name as follows, though : ch1_name = [ k for k, v in locals().items() if v == ch1][0] print(ch1_name, ch1) But I would personally just create an add...
by robbes
Wed Aug 15, 2018 4:18 pm
Forum: Python
Topic: How would I create a script to simulate arrow key clicks
Replies: 3
Views: 527

Re: How would I create a script to simulate arrow key clicks

Consider the keyboard package, available at PyPI. You have to be root to use it.
I think the command would just be
keyboard.press_and_release('right')
See https://pypi.org/project/keyboard/
by robbes
Wed Jun 27, 2018 4:34 pm
Forum: Python
Topic: Data Transfer From HTML Page to Python File
Replies: 1
Views: 228

Re: Data Transfer From HTML Page to Python File

If you don't want to write your own script, you can use BeautifulSoup: from bs4 import BeautifulSoup soup = BeautifulSoup('your_html_file', "lxml") data_list = soup.findAll(text=True) Use the requests module to generate 'your_html_file' if it a web site. You should be able to find the item you want ...
by robbes
Mon May 21, 2018 4:47 pm
Forum: Advanced users
Topic: Can't install Python Packages QUANDL, NUMPY, ....
Replies: 1
Views: 655

Re: Can't install Python Packages QUANDL, NUMPY, ....

Your error message ends with:
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel
Do you have python-dev installed?

You are apparently using python2.7 for this installation. Obsolescence is rapidly approaching! Python3 would be a better choice.
by robbes
Tue Apr 17, 2018 2:03 am
Forum: Python
Topic: Need advise on realtime programming
Replies: 8
Views: 780

Re: Need advise on realtime programming

On the programming logic side of things, have you looked into using a formal finite state machine model - for example the module called "transitions" at https://github.com/pytransitions/transitions ? It might save you a bit of grief in keeping track of the states.
by robbes
Fri Apr 13, 2018 7:29 pm
Forum: General discussion
Topic: Matplotlib installation problems.
Replies: 4
Views: 1594

Re: Matplotlib installation problems.

I just took a look at a Raspberry 3 B running stretch, with matplotlib installed some months ago. Looking through .bash_history, it appears to have been installed with sudo apt install python3-matplotlib , so the package should be available to you. Today I tried sudo apt install --only-upgrade pytho...
by robbes
Wed Apr 11, 2018 10:12 pm
Forum: Python
Topic: Where are python3 libraries searched for when using virtualenvs?
Replies: 2
Views: 270

Re: Where are python3 libraries searched for when using virtualenvs?

Have you activated the virtual environment? Once you have, then pip will automatically install packages to it until it is deactivated. If you want to use system packages, create the virtual environment with virtualenv --system-site-packages rather than providing a link. Python will always look in th...
by robbes
Sat Apr 07, 2018 5:51 am
Forum: Advanced users
Topic: error with luma.led_matrix
Replies: 17
Views: 1756

Re: error with luma.led_matrix

This thread started with "error in luma.led_matrix setup command: 'tests_require' must be a string or list of strings containing valid project/version requirement specifiers" Your (unformatted) code contains test_deps = [ 'mock;python_version<"3.3"', 'pytest>=3.1', 'pytest-cov' ] and tests_require=t...
by robbes
Fri Apr 06, 2018 6:19 pm
Forum: Advanced users
Topic: error with luma.led_matrix
Replies: 17
Views: 1756

Re: error with luma.led_matrix

Have you followed the installation instructions at https://github.com/rm-hull/luma.examples and further comments at https://luma-led-matrix.readthedocs.io/en/latest/install.html#examples ? The second URL isn't very useful, but if you download some of his examples you might find something to help.
by robbes
Sun Apr 01, 2018 4:41 pm
Forum: Python
Topic: Python & Matplotlib X Ax two hour time span from current time
Replies: 4
Views: 673

Re: Python & Matplotlib X Ax two hour time span from current time

By default, matplotlib is inserting tick values where you don't want them, but these can be over-ridden with the MinuteLocator or HourLocator function. Also, it is easier to see your data points if you suppress the default line style that matplotlib uses. import matplotlib.pyplot as plt import datet...
by robbes
Sat Mar 31, 2018 6:47 pm
Forum: Python
Topic: Python & Matplotlib X Ax two hour time span from current time
Replies: 4
Views: 673

Re: Python & Matplotlib X Ax two hour time span from current time

After an interlude of profound thought, I expect I was not addressing the problem you were having. You probably need to read
https://matplotlib.org/api/_as_gen/matp ... ticks.html
Turn your datetime objects into strings first.
by robbes
Sat Mar 31, 2018 4:46 pm
Forum: Python
Topic: Python & Matplotlib X Ax two hour time span from current time
Replies: 4
Views: 673

Re: Python & Matplotlib X Ax two hour time span from current time

I haven't looked at your program, but if you simply want to display a fixed number of data points, why not just

Code: Select all

plt.plot(x[-20:], y[-20:])
by robbes
Thu Mar 29, 2018 8:15 pm
Forum: Python
Topic: Python 3.5 & matplotlib - won't plot
Replies: 8
Views: 2122

Re: Python 3.5 & matplotlib - won't plot

You would have to restart the python interpreter after changing the rc file to pick up those changes.
Your program should certainly work if you include the line

Code: Select all

matplotlib.use('tkagg')
right after the

Code: Select all

import matplotlib
statement
by robbes
Thu Mar 29, 2018 7:10 pm
Forum: Python
Topic: Python 3.5 & matplotlib - won't plot
Replies: 8
Views: 2122

Re: Python 3.5 & matplotlib - won't plot

You are just getting a warning, not an error. Where is your matplotlibrc file? It should be $HOME/.config/matplotlib/matplotlibrc You can check (using python3 interpreter) with >>>import matplotlib >>> matplotlib.matplotlib_fname() Hopefully this file will have a line backend : agg which is the defa...
by robbes
Sun Mar 25, 2018 5:14 pm
Forum: Python
Topic: Issue with reading directory on raspberry
Replies: 9
Views: 873

Re: Issue with reading directory on raspberry

I don't know if this is the cause of your problem, but you have semicolons after each statement in your getImages() definition. They shouldn't be there.

Go to advanced search