I am running an app.py which imports googlemaps as
import googlemaps
But when I do a pip list, it lists googlemaps as
googlemaps 3.0.2
When I run the app,
Traceback (most recent call last):
File "app.py", line 40, in <module>
import googlemaps
ModuleNotFoundError: No module named 'googlemaps'
I am on Windows, Python 3.6.0
In order to be sure. that pip and your script use the same python version I suggest to call following commands from the same terminal window.
python3 -m pip freeze | grep -i googlemaps
python3 -c "import sys ; print(sys.exewutable)"
python3 -c "import sys ; print("\n".join(sys.path))"
Try even following line to prove that googlemaps is installed if not being called from your app
python3 -c "import googlemaps"
and
python3 app.py
If you do not call your app directly with python, then tell us how you start the app. This different way of calling might be why it is not pointing to the same python version / virtualenv than the one where you installed googlemaps
If you do not know how the app is exactly started (e.g. started by a web server or similar), then I suggest you add following lines to app.py
before the import line that fails.
import os, sys
# the next two l
with open(os.expanduser("~/debug.txt", "w") as fout:
fout.write("EXE: %s\n" % sys.executable)
fout.write("PATH:\n" + ("\n".join(sys.path)))
This should create a file named debug.txt,
that you can inspect
Related
when I go to run my program, I keep receiving the error message below:
pi#navio:~/cloudapp-raspi $ sudo python3 app.py
Traceback (most recent call last):
File "app.py", line 7, in <module>
from data_receiver import DataReceiver
ModuleNotFoundError: No module named 'data_receiver'
however, when I go in the app.py file (see below), I clearly have it being imported.
import logging, time, argparse, configparser, sys
import socket, os, signal, psutil, data_receiver
from subprocess import Popen
from drone import Drone
from connection_watchdog import ConnectionWatchdog
from data_receiver import DataReceiver
from utils import Utils
data_receiver is not a standard python package. If you are installing it from a third party source using a package manager (like pip), be sure to install it globally, i.e., something like sudo -H pip install <package_name>.
Otherwise, if you have a data_receiver.py in your system, make sure to put it in the same directory as your app.py.
I have a python file named "test_module.py" with the code
from scapy.all import *
and when i execute the file with python test_module.py the module is getting imported successfully but when I run the file using the command sudo python test_module.py it is saying the error
Traceback (most recent call last):
File "test_module.py", line 1, in <module>
from scapy.all import *
ImportError: No module named scapy.all
System info:-
Linux mint 20
Python 2.7.18
So, Please help me to fix this issue.
Did you do
sudo python -m pip install scapy
first ? your issue is likely just having two separate environments
perhaps, try :
pip install scapy
import sys
# and take the correct Path to your scapy , example :
sys.path.insert(1, '/home/Your NAME/anaconda3/lib/python3.8/site-packages/')
so I was trying to run a python code, but the shell kept telling me that no 'pymongo' module was found.
Now, I have python 3.5.1 installed.
when I run pip freeze | grep pymongo it returns pymongo == 3.2.2 so it's clearly installed. I tried to run pymongo from the shell rather than a script but I get the same error every time.
import pymongo
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'pymongo'
So, help? It worked fine a month ago or so..
It means PyMonogo module is not installed for your Python 3. In the shell you can check the installed modules for your python.
import pip
pip.get_installed_distributions()
Check if pymongo is listed there. You have to install pymongo for python 3.
I am trying to run a script in my django project as a stand alone. I am using Django 1.6, this is a development server so no uwsgi is used, and I am running in a python virtual server. The virtual environment seems good to me because I can run python runserver 0.0.0.0:9000 with no issues.
Here is my environment set up:
(bot)one#chat-dash /home/git/bot_server/bot_server/bot_server $ export DJANGO_SETTINGS_MODULE=bot_server.settings.local
(bot)one#chat-dash /home/git/bot_server/bot_server/bot_server $ echo $DJANGO_SETTINGS_MODULE
bot_server.settings.local
Here is the my script:
(bot)one#chat-dash /home/git/bot_server/bot_server/bot_server/bot_data $ cat req.py
import sys
import os
import datetime
import base64
import json
from generators import thread_generator
from do_request import do_request
os.environ['DJANGO_SETTINGS_MODULE'] = "bot_server.settings.local"
from .models import User, ThreadVault
Here is the output from running:
(bot)one#chat-dash /home/git/bot_server/bot_server/bot_server/bot_data $ python req.py
Traceback (most recent call last):
File "req.py", line 10, in <module>
from bot_data.models import User, ThreadVault
ImportError: No module named bot_data.models
(bot)one#chat-dash /home/git/bot_server/bot_server/bot_server/bot_data $
I found that the script will run correctly if outside/parent of bot_data. I will need to figure out why it the path of bot_data/req.py takes it outside of the Django enviroment.
So I have run into a funny problem when trying to use Flask, I can only run it from ~/ (home) and not from ~/Projects/projectfolder. I'm using Python 2.7.4 installed via their homepage, virtualenv and virtualenvwrapper. Every time it's the same:
$ mkvirtualenv project
New python executable in project/bin/python
Installing setuptools............done.
Installing pip...............done.
Then I install Flask:
$ pip install flask
[...]
Successfully installed flask Werkzeug Jinja2
Cleaning up...
Then I open Python from my home directory:
(project) $ python
>>> from flask import Flask
>>>
Then I quit and go to my project folder:
(project) $ cd ~/Projects/example
(project) $ python
>>> from flask import Flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "flask.py", line 1, in <module>
from flask import Flask
ImportError: cannot import name Flask
And I'm a bit lost as to why this is happening, anybody have any ideas?
According to you traceback, you have a module of your own called flask.py in ~/Projects/example.
The current directory is searched before the actual package installation path, so it shadows the "real" Flask.