I am working on a signal generator AD9833 and i am using a RaspberryPi with it.I found a python library for working with it.
The link to the library is - https://github.com/KipCrossing/Micropython-AD9833
When i try to use this library as explained in the code below, i am not able to import the module 'pyb'. I am not able to link or install from pyb import Pin.
I tried various approaches.I tried this link https://pybuilder.github.io/documentation/tutorial.html#.Xd6HOOhKiUk, which describes about virtual environment. I am able to get the things as enter image description here, but ultimately after many hours of try, i am at same place from where i started. Please guide. I am new to programming.
I even installed the Miropython as suggested, but still the term from pyb import Pin is not recognized.
Testing Micropython installation
try to install PyBoard package
pip install PyBoard
Related
I'm trying to use this function vtkGDALVectorReader from the vtk library.
Everytime I try to use it, it says it doesn't exist. I've tried a few different version of vtk now and even looked at peoples code where I know this works.
I see it on the github, I see it in the docs.. why is it not working in python? I am using pip installed verison - perhaps I have to build from source?
Is there some additional step to install GDAL capabilities in VTK ??
import vtk
vtk.vtkGDALVectorReader()
I tried to download an external module to test how it works, by simply downloading 'Simplejson' using pip in cmd(Window). I watched my teacher did it, and followed it the exact way but i ran into a problem.
Not sure what i did, because my teacher just told me to follow him, i think we created a virtual environment on python so that we can do more than one projects with various versions of python. Anyway, most of you will know that after creating a virtual environment in my folder that i work for coding, a 3 new folders will appear and 'Simplejson' will be inside Lib\site-packages. Even if i checked that Simplejson is still inside the file, some how i can not import it. Are there any way that i can solve it?
enter image description here
Please refer to the following to check the process of installing and using the module "Simplejson" in VS Code:
Please check whether the python currently used by the VS Code terminal is the same as the one displayed in the lower left corner of the VS Code: (python --version or pip --version)
(If they use different pythons, please open a new VS Code terminal, it will automatically enter the selected environment.)
Then install the module "Simplejson".
Check the installed modules: (pip show Simplejson)
Run:
Reference: Python Environments in VS Code.
I'm trying to import https://github.com/chrisconlan/algorithmic-trading-with-python in my code. I've never imported anything from GitHub before and have looked at various other questions that have been asked on Stack Overflow regarding this problem but it just doesn't work. When I try to run the 'portfolio.py' code for example I keep getting a ModuleNotFound error for 'pypm'. What exactly is the correct way to import such a module or the whole GitHub directory?
I'm working with Visual Studio Code on Windows.
You will need to pip install the module. In your case the command you would need to run is python -m pip install -U git+https://github.com/chrisconlan/algorithmic-trading-with-python. Once you have done that you need to find the name of the module. You can do this with pip list. Find the name of the module you just installed.
Then you just stick import <module name> at the top of your code with the rest of your imports.
What i used to do in this is to clone the repository on the folder where are installed the python's packages. This is useful when you do not want to use the pip cmd tool, keeping the pip's cache memory under control.
I'm currently doing the exercise in "Learn python the hard way".
In this exercise i have to install the lpthw.web frame work.
Having installed pip in windows, i open my terminal and hit
pip install lpthw.web
Everything then ends succesfully.
But when i browse C:\Python27\Lib\site-packages\lpthw.web-1.1-py2.7.egg-info and check the installed-files text i can't see the web.py.
Consequently when i try to import it in a simple script i get ImportError.
I don't have python 3 installed as book suggested for possible cause, so i don't know how to work around it.
Any suggestion?
I checked my path
import sys
sys.path
and saw that every single line was using the panda3d path.
As i was not really using it, unistalling it fixed my problem.
For me it was python version control on raspberry pi
(linux) 2.7 is default and does not work.
follow:
https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/configure-your-pi
have other errors now but the import web loads in python.
cheers!
I'm quite a newbie when it comes to Python, thus I beg foregiveness beforehand :). That said, I'm trying to make a script that, among other things, installs some Linux packages. First I tried to use subopen as explained here. While this can eventually work, I stumbled upon the python-apt API and since I'm not a big fan or re-inventing the wheel, I decided to give a try.
Problem comes when trying to find examples/tutorials on installing a package using python-apt. Searching the documentation I found the PackageManager class that has some methods to install a package. I tried some simple code to get this working:
apt_pkg.PackageManager.install("python")
This does not seem to work that easily, the install method expects apt_pkg.PackageManager instead of a plain String. Thus, looking a bit more, I found this example that looks promising, but I'm a bit reluctant to use since I don't really understand some of what is happening there.
Then, has anyone tried to install a package using python-apt or should I go for using plain-old subopen style?
Thanks!
It's recommended to use the apt module from the python-apt Debian package. This is a higher level wrapper around the underlying C/C++ libapt-xxx libraries and has a Pythonic interface.
Here's an example script which will install the libjs-yui-doc package:
#!/usr/bin/env python
# aptinstall.py
import apt
import sys
pkg_name = "libjs-yui-doc"
cache = apt.cache.Cache()
cache.update()
cache.open()
pkg = cache[pkg_name]
if pkg.is_installed:
print "{pkg_name} already installed".format(pkg_name=pkg_name)
else:
pkg.mark_install()
try:
cache.commit()
except Exception, arg:
print >> sys.stderr, "Sorry, package installation failed [{err}]".format(err=str(arg))
As with the use of apt-get, this must be run with superuser privileges to access and modify the APT cache.
$ sudo ./aptinstall.py
If you're attempting a package install as part of a larger script, it's probably a good idea to only raise to root privileges for the minimal time required.
You can find a small example in the /usr/share/pyshared/apt/progress/gtk2.py:_test() function showing how to install a package using a GTK front-end.