I just started learning to customize my foorprint in Kicad via python scripts. I got stuck on “import pcbnew” because it gave me the error “no module name pcbnew” all the time. I checked my Kicad folder and found all the py examples for script foorprint wizard, but there’s no file named “pcbnew.py”.
I’m wondering if it’s because I’m using python3.5 rather than python2.7 and how can I fix this problem. Should I download the pcbnew script from somewhere like Kicad Github (I searched a lot but didn’t find any really helpful solutions…)? Or should I re-install my Kicad or python? My Kicad version is 5.0.
Thanks a lot!
Kicad includes it own version of Python (Version 2.7.13 at time of writing for Kicad 5.1 but moving to python 3 shortly). You can access Kicad python via the Pcbnew python terminal Tools > Scripting console.
If you wish to run a script you have a couple of options.
Run it using the inbuilt python 2.7 using either the scripting console or specifying the Kicad python version in the shebang line (you will have to search for this but, in macOS, for instance it is found in /Applications/Kicad/kicad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python)
Import the kicad site-packages into the python environment you are using.
import sys
sys.path.insert(0,"/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/")
import pcbnew
Related
I got the P4 python module for win10 via the installer on their page: https://www.perforce.com/downloads/helix-core-api-python
Its for python 3.9, though I have tested it with both Python 3.10 and 3.9 and it always throws the error: No module named 'P4' when I try to use it inside visual code.
Interpreter is set up correctly (tried 310 and 39).
Im a bit lost here and would love some help.
The installer package installed the following files into site-packages:
P4.py
P4API.cp39-win_amd64.pyd
and a folder with 4 metadata files in it
P4.py on itself looks good, no errors.
Edit: Im trying to use it with Blender. Currently shipped python version within that is 3.10.2. Also tried a older blender version which uses 3.9.7.
Both wont work.
Visual studio code is known for it's bugs with python. You could try using "PyCharm". Make sure to install the modules from Pycharm's settings instead of terminal.
(I'm not sure if this is the reason, but it's worth the try. Had the same issue and the mentioned way solved it.)
I am using python 3.5 and I am doing Algorithms specialization courses on Coursera. Professor teaching this course posted a program which can help us to know the time and memory associated with running a program. It has import resource command at the top. I tried to run this program along with the programs I have written in python and every time I received ImportError: No module named 'resource'
I used the same code in ubuntu and have no errors at all.
I followed suggestions in stackoverflow answers and I have tried adding PYTHONPATH PYTHONHOME and edited the PATH environment variable.
I have no idea of what else I can do here.
Is there any file that I can download and install it in the Lib or site-packages folder of my python installation ?
resource is a Unix specific package as seen in https://docs.python.org/2/library/resource.html which is why it worked for you in Ubuntu, but raised an error when trying to use it in Windows.
I ran into similar error in window 10. Here is what solved it for me.
Downgrade to the Apache Spark 2.3.2 prebuild version
Install (or downgrade) jdk to version 1.8.0
My installed jdk was 1.9.0, which doesn't seem to be compatiable with spark 2.3.2 or 2.4.0
make sure that when you run java -version in cmd (command prompt), it show java version 8. If you are seeing version 9, you will need to change your system ENV PATH to ensure it points to java version 8.
Check this link to get help on changing the PATH if you have multiple java version installed.
Hope this helps someone, I was stuck on this issue for almost a week before finally finding a solution.
Programming noob here. I'm on Mac OS 10.5.8. I have Python 2.7.6 and have installed NLTK. If I run Python from Terminal, I can "import nltk" with no problem. But if I open IDLE (either from Terminal or by double-clicking on the application) and try the same thing there, I get an error message, "ImportError: No module named nltk". I assume this is a path problem, but what exactly should I do?
The directory where I installed NLTK is "My Documents/Python/nltk-2.0.4". But within this there are various other directories called build, dist, etc. Which of these is the exact directory that IDLE needs to be able to find? And how do I add that directory to IDLE's path?
Supplementing the answer above, when you install python packages they will install under the default version of python you are using. Since the module imports in python 2.7.6 make sure that you aren't using the Python 3 version of IDLE.
Please go through the link given below:
setting-up-nltk-with-python-idle-on-os-x-10-6
HTH! Thanks!
I've been using python 2.7 and after installation of python 2.7. All of the scripts have run successfully, but suddenly today, when I run python, it is recognized with python 2.6, so for one of the python packages I get the following error:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python:
No module named htseq-count
i am not sure why it happens. The path environment variable for python is set to:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/Resources/bin:${PATH}" export PATH
How do I fix this error?
If your code relies on a particular version of Python, you should specify python2.7 or python2.6 instead of just python.
If this "suddenly" happened it's possible that installing some other software modified your $PATH so that the old version of Python now has priority (it's possible for multiple versions to be on your $PATH; it uses the first one it finds).
If you move these two lines to the bottom of the file they're in (maybe ~/.profile) it may correct this.
PATH="/Library/Frameworks/Python.framework/Versions/2.7/Resources/bin:${PATH}"
export PATH
You can type which python in Terminal you can see what binary it finds when looking for python on your $PATH.
If you don't mind using Python 2.6, you can probably install the missing package by typing this in your terminal:
easy_install-2.6 htseq
I think you are applying different python version to be used.
type
which python
under your control.
see which python you are using, you should config the one using python 2.7
python --version
I'm running Windows 7, Python 2.6.4 and the latest version of Eclipse. I downloaded the boto library (http://code.google.com/p/boto/) and ran python setup.py install, which created boto-1.9b-py2.6.egg in C:\Python26\Lib\site-packages.
Importing a class - say, by doing 'from boto.sqs.connection import SQSConnection' - works fine from the python command line tool. But Eclipse will not find boto, despite the fact that it is using the same python interpreter as I am using when at the command line. I added the library as an external source folder, but that didn't work either. How can I properly import the boto library into Eclipse?
Thanks.
From the comment so can be marked as answered
In Preferences->Pydev->interpreter - Python what is the System libs value
For libraries that are required only in a single project, the best practice is to add them to the Project's PYTHONPATH and not the SYSTEM PYTHONPATH.
This is done by right clicking on the project -> Properties -> PyDev-PYTHONPATH -> External Libraries and then adding the required library using Add zip/jar/egg.