I'm trying to get ipython style table complete with pdb by using ipdb.
On a clean ubuntu 14.04 install (new aws instance) I run.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install ipython
sudo pip install ipdb
sudo pip install boto
Then boot up ipython, and try.
ubuntu#ip-10-0-0-244:~$ ipython
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.
IPython 2.3.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import ipdb
In [2]: import boto
In [3]: ipdb.set_trace()
--Call--
> /usr/local/lib/python2.7/dist-packages/IPython/core/displayhook.py(234)__call__()
233
--> 234 def __call__(self, result=None):
235 """Printing with history cache management.
ipdb> str.
str.capitalize str.encode str.format str.isdigit str.isupper str.lstrip str.rfind str.rsplit str.startswith str.translate
str.center str.endswith str.index str.islower str.join str.mro str.rindex str.rstrip str.strip str.upper
str.count str.expandtabs str.isalnum str.isspace str.ljust str.partition str.rjust str.split str.swapcase str.zfill
str.decode str.find str.isalpha str.istitle str.lower str.replace str.rpartition str.splitlines str.title
ipdb> boto.
boto.[tab] just sits there. If I'm reading the docs right this should work, but maybe I have miss-understood something.
If I define a simple script test.py
import boto
print(boto.__version__)
Then call:
ubuntu#ip-10-0-0-244:~$ python -m ipdb test.py
> /home/ubuntu/test.py(1)<module>()
----> 1 import boto
2
3 print(boto.__version__)
ipdb> n
> /home/ubuntu/test.py(3)<module>()
1 import boto
2
----> 3 print(boto.__version__)
ipdb> boto.
boto.BUCKET_NAME_RE boto.connect_autoscale boto.connect_emr boto.connect_s3 boto.os
boto.BotoConfigLocations boto.connect_beanstalk boto.connect_euca boto.connect_sdb boto.perflog
boto.BucketStorageUri boto.connect_cloudformation boto.connect_fps boto.connect_ses boto.platform
boto.Config boto.connect_cloudfront boto.connect_glacier boto.connect_sns boto.plugin
boto.ENDPOINTS_PATH boto.connect_cloudsearch boto.connect_gs boto.connect_sqs boto.pyami
boto.FileStorageUri boto.connect_cloudsearch2 boto.connect_ia boto.connect_sts boto.re
boto.GENERATION_RE boto.connect_cloudtrail boto.connect_iam boto.connect_support boto.regioninfo
boto.InvalidUriError boto.connect_cloudwatch boto.connect_kinesis boto.connect_swf boto.resultset
boto.NullHandler boto.connect_cognito_identity boto.connect_logs boto.connect_vpc boto.s3
boto.TOO_LONG_DNS_NAME_COMP boto.connect_cognito_sync boto.connect_mturk boto.connect_walrus boto.set_file_logger
boto.UserAgent boto.connect_directconnect boto.connect_opsworks boto.datetime boto.set_stream_logger
boto.VERSION_RE boto.connect_dynamodb boto.connect_rds boto.exception boto.storage_uri
boto.Version boto.connect_ec2 boto.connect_rds2 boto.handler boto.storage_uri_for_key
boto.boto boto.connect_ec2_endpoint boto.connect_redshift boto.init_logging boto.sys
boto.compat boto.connect_elastictranscoder boto.connect_route53 boto.log boto.urlparse
boto.config boto.connect_elb boto.connect_route53domains boto.logging boto.vendored
I get the behavior I'd like.
Does anyone know how to make the tab complete functionality work for the set_trace() work case?
-Thanks
Related
I want to use the UART on the 40 pin header (pins 8 and 10) of the AML-S905X-CC (Le Potato).
I have tried a couple of O/S like Raspbian Stretch Headless and Armbian, and while the boot and work fine, there seems to be no support for the on board UART on the 40 pin header.
I am happy to use any O/S which can provide this.
Do I need to use Device Tree Overlays to enable this?
If so, where can I download the devicetree overlay package and is there a tutorial or some documentation on the process.
If not, how can I use this onboard UART?
Thanks
This is what I do
ROOT###### ARNBIAN ONLY
wget https://raw.githubusercontent.com/libre-computer-project/libretech-overlays/for-4.13.y/overlays/meson-gxl-s905x-libretech-cc-i2c-ao.dts
sudo armbian-add-overlay meson-gxl-s905x-libretech-cc-i2c-ao.dts
end ROOT #####
If Ubuntu
git clone https://github.com/libre-computer-project/libretech-wiring-tool.git
cd libretech-wiring-tool
sudo make
It works for me:
wget https://raw.githubusercontent.com/libre-computer-project/libretech-overlays/for-4.13.y/overlays/meson-gxl-s905x-libretech-cc-uarta.dts
sudo armbian-add-overlay meson-gxl-s905x-libretech-cc-uarta.dts
python3 -m serial.tools.miniterm
--- Available ports:
--- Enter port index or full name:
Never port appears, but the uarta is working in /dev/ttyAML6.
python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser = serial.Serial()
>>> ser.baud = 9600
>>> ser.port = '/dev/ttyAML6'
>>> ser.open()
>>> ser.write(str.encode('test'))
4
>>>
Serial comm over the port /dev/ttyAML6 works!
I use debhelper with python setuptools in order to build my packages.
I recently updated the compatibility level 9 to 11 in order to use the systemd timers.
From that moment every time I upgrade the package the service contained is restarted.
I tried to build with the following rules:
#! /usr/bin/make -f
#export DH_VERBOSE = 1
export PYBUILD_NAME=my_pkg
export DH_ALWAYS_EXCLUDE=CVS:.svn:.git:.vscode*
export PYBUILD_INTERPRETERS=python3
%:
dh $# --with python3 --buildsystem=pybuild
override_dh_installinit:
dh_installinit --no-stop-on-upgrade --no-restart-on-upgrade --no-restart-after-upgrade --no-start
override_dh_systemd_enable:
dh_systemd_enable --name=my_pkg
override_dh_systemd_start:
dh_systemd_start --no-stop-on-upgrade --no-restart-on-upgrade --no-restart-after-upgrade --no-start
python3 setup.py clean --all
According to the documentation those tags should do what I look for but probably there is something I'm missing:
dh_systemd_start
dh_installinit
Every time I update it the service contained is restarted.
The service is running the update itself so when is restarted the update is left uncompleted.
As expected I was looking in the wrong direction.
The correct option to use is:
dh_installsystemd
change the rule file into:
#! /usr/bin/make -f
#export DH_VERBOSE = 1
export PYBUILD_NAME=my_pkg
export DH_ALWAYS_EXCLUDE=CVS:.svn:.git:.vscode*
export PYBUILD_INTERPRETERS=python3
%:
dh $# --with python3 --buildsystem=pybuild
override_dh_systemd_enable:
dh_systemd_enable --name=my_pkg
override_dh_installsystemd:
dh_installsystemd --no-restart-after-upgrade
override_dh_systemd_start:
python3 setup.py clean --all
I hope this will help someone else in the same situation.
I tried setting up virtual environment for Python 3.9 using virtualenvwrapper and got this error.
➜ mkvirtualenv env --python=$(which python3.9)
RuntimeError: failed to query /usr/bin/python3.9 with code 1 err: 'Traceback (most recent call last):\n File "/home/sid/.local/lib/python3.6/site-packages/virtualenv/discovery/py_info.py", line 16, in <module>\n from distutils import dist\nImportError: cannot import name \'dist\' from \'distutils\' (/usr/lib/python3.9/distutils/__init__.py)\n'
What am I missing?
apt-get install -y python3.9-distutils
then it should work fine.
I have anaconda python3 kernel with pytorch and numpy installed in the environment. In jupyter notebook first line 'import torch' produces error.
I am using anaconda navigator to launch jupyter notebook and enter my environment and see pytorch is installed but not being imported. Tried various dir extensions 'from torch... import * but more error
import torch
ImportError Traceback (most recent call last)
<ipython-input-1-20507c95d9af> in <module>
1
----> 2 import torch
3
4
~/anaconda3/envs/udacity1/lib/python3.6/site-packages/torch/__init__.py in <module>
100 pass
101
--> 102 from torch._C import *
103
104 __all__ += [name for name in dir(_C)
ImportError: /home/frida/anaconda3/envs/udacity1/lib/python3.6/site-packages/torch/lib/libtorch.so.1: undefined symbol: nvrtcGetProgramLogSize
I was able to add this to the end of my path to establish a 'backend ' for my notebook kernel. Thanks to Kris Stern!
-m ipykernel install --user
first get your kernel path with
(which python3)
then connect it using
sudo (your path)/anaconda3/bin/python3 -m ipykernel install --user
Environment is Ubuntu 12.x LTS 64 bit. I ran the install as follows :
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
Everything installed great, and I tried out the 'getting started' example only to come upon this error as if my env. is't set correctly..
See orig # http://www.scipy.org/getting-started.html
usernamep#ubuntudev:~$ ipython --pylab
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Welcome to pylab, a matplotlib-based Python environment [backend: TkAgg].
For more information, type 'help(pylab)'.
In [1]: from scipy import special, optimize
In [2]: f = lambda x: -special.jv(3,x)
In [3]: sol = optimize.minimize(f, 1.0)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/user/<ipython-input-3-ea43eb308d3c> in <module>()
----> 1 sol = optimize.minimize(f, 1.0)
AttributeError: 'module' object has no attribute 'minimize'
In [4]:
Do I need to reform their example's import? Checking their docs now...
optimize.minimize was introduced in Scipy v.0.11 (see http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html ).
On Debian, that would mean that you need Jessie or better. On Ubuntu, you appear to need raring or better.
Almost certainly the scipy you installed using apt-get is simply too old to have minimize: (0.10, I'd guess). The code works for me:
>>> from scipy import special, optimize
>>> def f(x): return -special.jv(3,x)
>>> sol = optimize.minimize(f, 1.0)
>>> sol
status: 0
success: True
njev: 17
nfev: 51
hess_inv: array([[ 4.70024446]])
fun: -0.43439442684052476
x: array([ 4.20118891])
message: 'Optimization terminated successfully.'
jac: array([ -3.72529030e-09])
I think you'll be better off using pip to install the stack.
python-scipy package in the Ubuntu 12 is a bit old. I think it is ver 0.9.0. The optimize.minimize function was added to scipy ver 0.11.0.