I'm more specifically wanting to know whether sqlite3 and json comes with python IDLE or do I have to install them separately to use them inside IDLE, If so can anyone link me to those installing procedures of sqlite3 and json on Python IDLE?
I also want to know where I can find the list of other pre-installed packages that comes with basic Python IDLE (i.e. Python 2.7.14) . I am a Beginner and it would be really helpful.
Thank you.
To get a list of your packages, from your terminal, launch python :
python
Then
help("modules")
Another solution, if you want to check if json or sqlite3 are installed, start Python from your terminal :
python
Then import sqlite3 and json:
import json
import sqlite3
You can check theirs version with :
>>> json.__version__
'2.0.9'
>>> sqlite3.version
'2.6.0'
IDLE is part of the CPython standard library and is usually installed when tkinter (and turtle) are. It provides an optional alternate interface for running your code with a particular python binary. When you run code through IDLE, it is run by the python binary that is running IDLE. So the same modules are available whether you run code through the terminal interface or through IDLE. There is no separate installation.
Related
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
I'm a complete beginner in Python programming. I have trouble installing/importing the module 'requests' on python. When I use my command terminal to install requests, I get a message that requests is already installed. However, when I try to import requests into the file I'm working on, python tells me there is no such module installed.
Sorry to bother you with this silly and probably easy question, thanks in advance!
If you use PyCharm (which is a great choice in my opinion), go to the tab Run and select Edit Configuration and in the window that just opened make sure the your Python interpreter is the one you used when you pip installed the package you asked about.
You can check your Python version or just see in PyCharm if the requests is actually installed by going to the tab File, select Settings, click on Project: name_of_your_project and finally check in Project Interpreter that the package is installed.
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 installed BeautifulSoup for Python 3 (python3-BeautifulSoup-1:3.2.0-4.fc16) on Fedora 16(64bit) using the Add/Remove Software GUI tool. It appears to have installed correctly (yum info python3-BeautifulSoup shows 'Repo: Installed') but when I try to import BeautifulSoup (using import BeautifulSoup statement) in the interactive shell I get an 'ImportError: No module named BeautifulSoup' message.
I've also got BeautifulSoup for Python 2 (python-BeautifulSoup-1:3.2.0-4.fc16) installed h working fine with Python 2.7.2.
The summary appears weird (Monitor filesystem events with Python under Linux) though the descrition makes sense. Where do I start?
I'm new to Python (trying to learn Python3 in my spare time) and I'm not a programmer. I'm trying to learn by writing simple code and following code examples (hence the need for BeautifulSoup.) Please assume minimal Python (and linux) knowledge.
$ repoquery -l python3-BeautifulSoup
/usr/lib/python3.2/site-packages/beautifulsoup4-4.0.0b3-py3.2.egg-info
/usr/lib/python3.2/site-packages/bs4
/usr/lib/python3.2/site-packages/bs4/__init__.py
...
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