I want to start with I am new to the python language and am learning on my own. My issue is that I am installing the modules that I'm trying to use. The installs are successful but do not exist when I try to import them. I am using Visual Studio Code, Python 3.6, and Anaconda on Windows 10.
I am trying to use pyttsx3, SpeechRecognition and pocketsphinx.
$pip list
This gives me a very large list but does not contain either of my installed modules.
$python -m pip list
Gives me smaller output with them.
Package Version
----------------- ---------
beautifulsoup4 4.6.0
bs4 0.0.1
certifi 2018.4.16
chardet 3.0.4
click 6.7
gTTS 2.0.0
gTTS-token 1.1.1
idna 2.6
pip 10.0.1
pocketsphinx 0.1.3 #Here
pypiwin32 223
pyttsx 1.1
pyttsx3 2.7 #Here
pywin32 223
requests 2.18.4
setuptools 39.1.0
six 1.11.0
SpeechRecognition 3.8.1 #Here
urllib3 1.22
wheel 0.31.0
I know their installed but when I try to use any of the imports.
$python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyttsx3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyttsx3'
I am fine with this being something small on my part due to my lack of knowledge with this language, but I have done a full days worth of research trying to solve this myself.
Edit:
$pip --version
pip 9.0.1 from C:\Users\Keiro\Anaconda3\lib\site-packages (python 3.6)
You have two versions of pip perhaps two different installations of python as well. One with Anaconda and other one by main site.
Stick to one version and if you install in that use that environment in Visual Studio(Or VS Code)
You have installed those in anaconda which the standard installtion of Python wont recognize..
Open Python prompt from Anaconda Navigator >> Choose the environment (Select base for default) >> Open with Terminal [Or Open with Python]
>>python
>>import pyttsx3
In Visual Studio code set the same environment
Ctrl+Shift+P >> Select Python interpreter
Choose the anaconda location.
Volla. Now it should work
I had the same problem and found the answer in an old forum.
Write "pip3" instead of "pip".
So the code is:
pip3 install pyttsx3
(Source: bash: pip: command not found)
Related
When I try to install my library locally and test it, it shows up as installed:
PS C:\Projects\pypi\potatoutils> pip install -e .
Obtaining file:///C:/Projects/pypi/potatoutils
Installing collected packages: potatoutils
Attempting uninstall: potatoutils
Found existing installation: potatoutils 0.0.1
Uninstalling potatoutils-0.0.1:
Successfully uninstalled potatoutils-0.0.1
Running setup.py develop for potatoutils
Successfully installed potatoutils
But when I try to test it
PS C:\Projects\pypi\potatoutils> python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import potatoutils
I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'potatoutils'
What am I doing wrong?
EDIT: pip and python have the same version (3.7) and their paths match.
And the library shows up when I use pip list.
Often this is the issue if you pip install a package with pip for python2.x
but then when you attempt to import your library for python3.x
Make sure you're running installing pip packages for the correct python version.
use pip3 using pip sometimes point to python 2.x versions, that's why maybe it can help!
Okay, so I managed to get the library up and running by starting over and following these instructions:
https://medium.com/analytics-vidhya/how-to-create-a-python-library-7d5aea80cc3f
I still don't know what went wrong the first time (maybe outdated instructions?) but it no longer matters to me.
I recently ran pip install pyodbc. Which says it installed pyodbc successfully on the cmd.
However when I do import pyodbc in IDLE I receive an error saying 'No module named pyodbc'.
It seems only two files have been installed when I ran pip install pyodbc.
The two files:
pyodbc-4.0.26.dist-info
pyodbc.cp36-win32.pyd
VERSION of Python:
Python 3.6.3
Complete Error Message:
Error Message
How do I resolve this issue? Any help would be much appreciated, I'm new to python and this is quite frustrating.
The files that installed are fine. *.pyd is compiled library (see https://docs.python.org/3/faq/windows.html#is-a-pyd-file-the-same-as-a-dll).
Issues that may cause this:
IDLE running main python installation and you installed the package in virtual environment
You have several installations of python e.g. python 3.x alongside python 2.x
I think first of all try to run all the steps from the same cmd:
PS C:\Windows\system32> pip install pyodbc
Collecting pyodbc
Using cached https://files.pythonhosted.org/packages/17/00/7115c072d4d01da4feee740cf5d964b4367ba0f9843d334d64ef77fd2baa/pyodbc-4.0.26-cp36-cp36m-win_amd64.whl
Installing collected packages: pyodbc
Successfully installed pyodbc-4.0.26
# now just run python interpreter
PS C:\Windows\system32> python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
# no error
This should work...
And then try to understand if you have several virtualenvs or python instalations.
You can check which python IDLE run, by right click on it's shortcut and "open file location" for example
I am trying to install scrapy and for that I have installed python 2.7 and conda(as pip was giving me errors that i couldn't solve.) after that I created a separate environment for scrapy named py2 with conda.
With this output I suppose that scrapy is installed successfully on my machine.
[py2] C:\Users\ADMIN>conda install -c https://conda.anaconda.org/scrapinghub scrapy
Fetching package metadata: ......
Solving package specifications: ...........................
# All requested packages already installed.
# packages in environment at C:\dev\Anaconda3\envs\py2:
#
scrapy 1.0.3 py27_2 scrapinghub
Now I make it sure that it is python 2.7 I executed this
[py2] C:\Users\ADMIN>py
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Which is also correct I suppose.
Now still I am unable to do this
>>> import scrapy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scrapy
which indicates that scrapy is not installed.
Environment : Windows 8 (64 bit)
I am a beginner both in python and scrapy.
There are interestingly a few hacks that are needed to run Scrapy on Windows.
You would need to install unofficial support for Windows in Python, look for PyWin32 section:
http://www.lfd.uci.edu/~gohlke/pythonlibs/ Afterwards remember to run postinstall.py -install as advised on this page.
Depending how you are setup, you might need to install C++ compiler for Python, required to run lxml:
https://www.microsoft.com/en-us/download/details.aspx?id=44266
Please look for similar questions referring to overall Python not only Scrapy e.g. error: Unable to find vcvarsall.bat Depending on how you are setup you will find hints around.
As it was all in virtual environment of conda, while installing scrapy I needed to pass the name of conda virtual environment, except that scrapy would have been installed in the root(I mean outside the environment or for the machine.)
So for py2 virtual environment, after activating this, following command will install scrapy:
conda install -n py2 -c https://conda.anaconda.org/scrapinghub scrapy
Here py2 is environment's name.
This page helped me to figure out what was happening here.
I must say python is not that easy to learn.
Edit: Before you start deleting/modifying installs, please glance over StvnW's answer/summary to make sure you are applying the solution that is appropriate for you.
I've installed python 2.7.5 and pip [edit: mac OSX Mountain Lion.] I've run "pip install praw" in terminal. All good. When I run python and run "import praw" I get:
...$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named praw
...same ImportError from a script.
when I install praw I get this:
$ pip install praw
Downloading/unpacking praw
Downloading praw-2.1.10.tar.gz (83kB): 83kB downloaded
Running setup.py egg_info for package praw
Requirement already satisfied (use --upgrade to upgrade): requests>=1.2.0 in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): six in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): update-checker>=0.6 in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): setuptools in
/usr/local/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg (from update-
checker>=0.6->praw)
Installing collected packages: praw
Running setup.py install for praw
Installing praw-multiprocess script to /usr/local/bin
Successfully installed praw
Cleaning up...
In python if I run help('modules') it isn't there.
Relatively new to python and I haven't been able to sort this out with google search. Any hints would be much appreciated.
Edit:
SitRep:
I've uninstalled 2.7.2, uninstalled praw, and uninstalled (homebrew) pip. I ran python 2.7.5 and it couldn't find the module (as you would suspect.) I then reinstalled pip with easy_install and now 2.7.5 is finding praw but giving this error:
$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/praw/__init__.py", line 43, in <module>
from update_checker import update_check
File "/Library/Python/2.7/site-packages/update_checker.py", line 11, in <module>
from pkg_resources import parse_version as V
ImportError: No module named pkg_resources
>>>
Thanks for the help so far, the spurious install was the root of problem 1.
The solution to the final problem can be found here:
No module named pkg_resources
I wish there were some way to summarize this for future readers, but I've done so many things that I no longer recall what addressed what. I basically uninstalled everything (python 2.7.2, 2.7.5, praw, pip,) reinstalled 2.7.5 from http://python.org/download/, reinstalled pip with easy_install (and sudo command) instead of homebrew, reinstalled praw with sudo command, and followed the directions for the subsequent module error in the link above. Hope that helps. :)
The OS X system versions of Python live in /System/Library/Frameworks/Python.Framework/<verson>, each of which links to /Library/Python/<version>/site-packages. Seems like you have installed another version of python and/or pip to /usr/local, but when you invoke python you are still getting the system version.
Try this:
$ /usr/local/bin/python
>>> import praw
I'd also recommend looking into tools like pyenv and virtualenv if you are going to do any amount of work with Python. Pyenv lets you easily manage and switch between multiple versions (including micro versions x.x.3, x.x.5, etc). Virtualenv lets you create isolated Python environments where you can pin down versions of site-packages specific to a particular project.
Edit (summarizing):
sudo easy_install pip will install pip under /System/Library/Python/<version>. Calling that pip will install packages to /Library/Python/<version>/site-packages
brew install python will install a second version of python — including pip — under /usr/local/. That pip will put packages in /usr/local/lib/python<version>/site-packages/`.
One version may not see packages installed to the other.
which python and which pip are helpful for troubleshooting.
Dean's final solution above results in user packages being installed to the system site-packages.
Despite Dean's choice to update the system Python, many would advocate instead using brew, pyenv, and virtualenv to isolate oneself from the system Python.
It's strange. I am suspecting you have another version of python2.7 on your mac os
If you are using a mac. Check the version of python on your shell's path using which python. Then make sure that the shebang line in the script you are trying to run uses the same version of python.
In my terminal I typed
which python and got the output /usr/local/bin/python
I went to the script I was trying to run and added the following to the first line
#!/usr/local/bin/python
Then I went back to my terminal. Checked that I was in the same directory as the script I wanted to run and typed
./my_script.py
If you don't see any output at this point make sure that you have execution permission enabled for your script by typing chmod +x my_script.py in ther terminal. Then try running the script again using ./my_script.py
I am trying to get ipython notebook run.
I already installed pyzmq.
Do you know why it's still giving this error?
The only reason you would be seeing that error (having manually installed pyzmq) is if pyzmq was installed to a different pythonpath than where ipython is running from.
If you followed the install instructions, you should have no problems:
easy_install ipython pyzmq tornado
# or
pip install ipython pyzmq tornado
It is also possible that the installer saw the dependency already satisfied in another location and didn't do anything, and then ipython might be running with a different pythonpath that isn't seeing it. You can force an upgrade of everything:
easy_install -U ipython pyzmq tornado
pip3 uninstall pyzmq
pip3 install pyzmq
Worked for me
Try the following:
pip3 install --upgrade pip
pip3 install jupyter
The above assumes you have aliased pip to pip3.
check what version on python you installed it with
python --version
When you run the application make sure you are using that same version you used to install it with.
The problem for me was that I installed it for python 3.6 but ran it under python 2.7
I have all the packages installed & it also shows up in the path but does throw the same error
jabira#ubuntu:~$ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/share/pyshared/zmq', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7']
>>>
jabira#ubuntu:~$ ls /usr/share/pyshared/zmq/
core devices eventloop green __init__.py log ssh tests utils web
jabira#ubuntu:~$ less /usr/share/pyshared/zmq/__init__.py
jabira#ubuntu:~$ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named zmq
>>>
jabira#ubuntu:~$ dpkg -l|grep zmq
ii libzmq3 3.2.2+dfsg-1lucid lightweight messaging kernel (shared library)
ii python-zmq 2.2.0.1-1lucid3 0MQ is a fast messaging library
jabira#ubuntu:~$
you should add Phython path to windows local variable PATH before install zmq
For me the solution was to rename my script from zmq.py to anything else.
This happens because using the name zmq.py crates a name conflict with the package as python tries to include the script itself rather than the library as scripts have priority in the include hierarchy.
I had a file that was trying to import zmq that was throwing:
ModuleNotFoundError: No module named 'zmq'
But pip install zmq or pip install pyzmq kept telling me I had a version already installed, and thus Requirement already satisfied at Library/blahblah/Python/3.6 ...
I've already aliased pip3 to pip, but trying pip3 didn't work either
I wound up having to reset my $PYTHONPATH and deleted that Python 3.6 install I didn't actually need.
After that pip install pyzmq STILL didn't work though.
What finally worked was pip3 install zmq ... Weird since I already had that aliased, but something w/the paths might still be screwy.
On Ubuntu 20.04 and Python 3.9, this did the trick for me:
sudo apt-get install python3-zmq
Source: https://askubuntu.com/a/100543