On my raspberry pi 3, I am trying to run this code, but I get this error:
No module named google.auth.transport.grpc
I have installed all packages listed in the requirements.txt (on the same github page above), and installed grpcio. I have installed google-auth. I have installed google-assistant-sdk. I have no clue why this module is not working correctly. If I open up python and try: import google.auth it gives the same error of "No module named google.auth"
Any ideas as to how I can fix this?
Try to verify the version of Python that you are using to run this code. If you installed the module in Python 2.x and try to run it with Python 3.x it will not work, because modules installed on Python 2 are not usable in Python 3 and vise versa.
I was trying to run the program with python -m textinput.py, which used python 2.x
Using python3 -m textinput.py fixed my issue by using python 3.x
My goal is to import gensim in Python 3 on Windows.
I am using Python 3.7.2 (checked by running python -V in Windows command prompt). I installed gensim by running pip install gensim. I checked the installation by running pip freeze, and saw the line gensim==3.7.3.
Then, I ran the command py to enter the interactive python mode (still in Windows command prompt). I ran the line import gensim and got the following output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gensim'
I also tried from gensim import test and got the following output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gensim'
Any suggestions? How do I install gensim on Windows with Python 3? How do I test gensim?
In Mac, open anaconda navigator, Click on 'Open Terminal option'. If you are using Windows, Run anaconda prompt as administrator and run the following command:
conda install -c conda-forge gensim
I think you have installed it using normal cmd, so it may have installed it on python2.x. Install it with anaconda prompt.
Let me know if it worked for you.
I got the same error after installing gensim in Anaconda. It worked only after I re-started the Anaconda: by exiting it, and re-opening it via the command prompt. I wanted to share this experience since someone else may meet the same issue.
To understand why this happens, you must know how Windows finds executables to run, and how the Python software is installed.
When running a command, Windows searches for an executable in the environment variable PATH. It executes the first one found.
python.exe is installed in <PYTHON_INSTALL_DIR> (e.g. C:\Python\3.7).
pip.exe and other Python tools (e.g. pylint, virtualenv, pycrust, etc.) are installed in <PYTHON_INSTALL_DIR>\Scripts.
py.exe is installed in your Windows system directory (e.g. C:\Windows).
python and pip commands use the modules found in the directory their installed in, they do not look at PATH.
So, let's say you have the following Python versions:
C:\Python\2.7
C:\Python\3.6
C:\Python\3.7
and your PATH environment contains the following directories:
C:\Python\2.7
C:\Python\3.6\Scripts
then, see the following output:
C:\>python -V
Python 2.7.16
C:\>pip -V
pip 19.1.1 from c:\python\3.6\lib\site-packages\pip (python 3.6)
C:\>py -V
Python 3.7.3
So, when running pip, it is possible that the packages are installed in another Python version then the version you'll get when running python.
To see which versions are (correctly) installed on your system, run py -0p. Example output:
C:\>py -0p
Installed Pythons found by py Launcher for Windows
-3.7-64 C:\Python\3.7-64\python.exe *
-3.7-32 C:\Python\3.7-32\python.exe
-3.6-64 C:\Python\3.6-64\python.exe
-2.7-64 C:\Python\2.7-64\python.exe
-2.7-32 C:\Python\2.7-32\python.exe
General solution (for Windows)
The best thing is not to rely on your system PATH. Use the py launcher to select the version you want. To run the pip module corresponding to the Python version you want to use, start pip as a module instead of executable.
So instead of:
pip install <package>
run:
py -3.6 -m pip install <package>
Here's My hypothesis towards your situation, since your OS is able to recognize both python and py commands in commandline, this may mean that you have two separate versions of python installed.
Since, as you mentioned that python -V shows gensim as an installed module. Try opening python interactive interpreter via command python instead of py, and import gensim module in it.
C:\Users> Python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gensim
see if that works.
P.S.
I would not recommend having two different compiler versions on a single OS as it creates a lot of commotion, and create incompatibility issues with program's made on one compiler with the other. And makes problems (like you mentioned) a lot more prevalent.
Most probably you have > 1 python installed in your machine. To install gensim (or any package) inside python command line, you can run below:
type "python" then enter
type "import subprocess" then enter
type
"subprocess.check_call(["python", '-m', 'pip', 'install', 'gensim'])"
then enter
Sample below:
>>> import subprocess
>>> subprocess.check_call(["python", '-m', 'pip', 'install', 'gensim'])
Collecting gensim
..
...
Installing collected packages: smart-open, gensim
Successfully installed gensim-3.7.3 smart-open-1.8.3
0
I already installed the latest version of Python 3 and I installed Pygame using the terminal I also included import Pygame in my file however when I run the file it refuses to open and displays the error message "no module named pygame"
What's the problem?
What's the solution?
Try python3 first.py in your terminal.
Or in your file first.py add this line at the top:
(I used python3.x but you should add the correct version of your python 3)
#!/usr/local/bin/python3.x
To see your version:
$ python3 -V
Python 3.5.2
To see your python 3 path:
$ which python3
I recently tried to uninstall Python 3.5.2 and installed Python 3.6.0. I used to use python in the command line to run Python 3.5.2 from the command line, and py to run Python 2.7.12. Now, python runs Python 3.5.2, and py runs Python 3.6.0. I am running Windows 10, and python3, python2, py2, and py3 do not do anything.
Don't bother adding Python to the path. Just use:
py Run highest version of Python (override with PY_PTYHON environment variable).
py -2 Run highest version of Python 2.
py -3 Run highest verssion of Python 3.
py -2.7 Run Python 2.7.
py -2.7-32 Run python 2.7 32-bit when on a 64-bit system.
More: https://docs.python.org/3.6/using/windows.html#python-launcher-for-windows
Note you can also specify in scripts which version to use as well with, for example:
#!python2
#!python3
#!python2.7
I have an existing Python 2.4 and it is working properly with tkinter as I tested it using
python
import _tkinter
import Tkinter
Tkinter._test()
Now, I have installed python 2.5.2 but when I try the same tests (with the newer version), it returns (but the same tests are working for the previous version)
ImportError: No module named _tkinter
I know that tcl8.5 and tk8.5 are installed on my machine as the following commands return there locations
whereis tcl
tcl: /usr/lib/tcl8.4 /usr/local/lib/tcl8.5 /usr/local/lib/tcl8.4 /usr/share/tcl8.4
whereis tk
tk: /usr/lib/tk8.4 /usr/local/lib/tk8.5 /usr/share/tk8.4
Any ideas how do I make my newer python version work with tkinter?
The files you found are for linking directly to tcl/tk. Python depends on another library as well: _tkinter.so. It should be in /usr/lib/python2.5/lib-dynload/_tkinter.so.
How did you install python2.5? If you are using Debian or Ubuntu you need to install the python-tk package to get Tkinter support.
If the _tkinter.so file is there, your environment could be causing problems.
If
python -E -c "import
Tkinter;Tkinter._test()"
suceeds, but
python -c "import
Tkinter;Tkinter._test()"
fails, then the problem is with how your environment is set up. Check the value of PYTHONPATH is set correctly.