can't import GoogleMaps in python [duplicate] - python

This question already has answers here:
Getting Python error "from: can't read /var/mail/Bio"
(6 answers)
Closed 9 months ago.
I'm new to Python and also new to Linux. I want to know why this code doesn't work?
(gmapenv)teruun#ubuntu:~/gmapenv$ python -c 'import googlemaps'
(gmapenv)teruun#ubuntu:~/gmapenv$ from googlemaps import GoogleMaps
and it says:
from: can't read /var/mail/googlemaps
what does this mean? what does from: can't read mean?

You need to install whatever Python libraries using e.g. pip or easy_install before you can import the googlemaps module in your Python code. This is because there is no GoogleMaps library that is built in to the Python standard library. I see you've already gotten started with using virtualenv, which is good. Also, perhaps you already installed a library, but maybe you installed the wrong one, or you installed it globally and then created a virtualenv, which by default is isolated from your globally installed packages. So either create a non-isolated virtualenv (not recommended) or install the package into the virtualenv (and uninstall globally).
Also, the second line you posted attempts to execute Python code directly on Bash, which doesn't work for obvious reasons, and gives a cryptic error message because Bash thinks you're expecting it to be a Bash command, and it just so happens that from actually is a command.

Related

SyntaxError when installing modules [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed last month.
When I try to install packages, e.g. pypdf2, I get a syntax error:
I tried to change the environment variables like is done in other questions on this topic but I do not succeed in solving this problem. Can someone provide a step-by-step walkthrough in solving this problem for a Python beginner?
You are trying to execute pip install as if it is a python command: but it isn't.
You need to execute all pip commands from the normal O/S command line - since you are in Pycharm you can simply type those pip commands from the Terminal window (the one you used to try to run the script).

Importing python modules works in command line but not in the python 3.8 shell

I'm having a problem with importing modules in python.
When I run my program in the command line it works perfectly fine.
However, when I try to run the same program in the python shell I am prompted with the following error:
ModuleNotFoundError: No module named 'matplotlib'
I already successfully installed matplotlib using 'python -m pip install matplotlib'.
I've read this can happen when you have two different versions of python installed; however, I don't.
I've uninstalled and reinstalled python and I still am having the same issue. I've also uninstalled and reinstalled matplotlib using pip.
I believe my problem is the module paths that python uses to search for imported modules are different between the two.
When I use the 'print(sys.path)' command in the python shell and the command line I get two different outputs.
Any help would be greatly appreciated!!!
The file different system paths between the python shell and the command line
You have two versions of python. I would recommend you to remove all pythons you have and go for anaconda https://www.anaconda.com/distribution/. It will fix your path problems and allow you to create environments with different versions of python. This is the least painful way also for future :) good luck.
I suppose, you have both of the Python versions installed on the same computer.
If that is so, then my answer would be to go inside both Python script folders and install matplotlib on both of them.
I have also faced that issue. My path includes pip of Python 3.7.1 and whenevwer I try to import modules on Python 3.4. It throws an error!
Maybe, you could add both of the Pythons to the path.
I encountered this same problem – python -c "import sklearn" would work just fine, but import sklearn inside a Python program failed. Both my one-liner and program was using the same Python version (version 3.8.10).
I eventually got the program to work by replacing the shebang line (originally #!/usr/bin/python) with #!/bin/env python.
I don't know why this worked exactly (sorry). Presumably some path got reset, and the module loaded from a different location, but it might help someone so I'm posting it here nontheless. (If you know more, feel free to edit this answer.)

Import openpyxl failing in Pycharm [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 5 months ago.
Successfully installed the openpyxl module with pip. It imports no problem on the python terminal, but imports fail in Pycharm.
Thought I might have messed up the installation so uninstalled the module and reinstalled.
After reinstalling the second time, checked if python recognized the module and if it works. It passed both those checks. But when using Pycharm and using the import command it doesn't work.
Hoping someone with more experience with Pycharm can help. Attached related screenshots below. I am using Python 3.7 (32-bit).
If I am missing any information or breaking any rules please let me know.
https://imgur.com/a/2A5VymR
Thank you all in advance.
Uninstall Pycharm
Reinstall Pycharm but with this setting make sure to click on "add launchers dir to the PATH"
Installing setting:

Getting "no module named builtin" ImportError

I'm getting:
"ImportError: No module named builtins"
that has only started happening after I installed a later version of PsychoPy (an application that uses Python that is used for writing psychology experiments). I was not getting this problem with an older version
I tried doing "sudo pip install future" like someone else recommended for fixing a similar problem. However, when I do this I get an "invalid syntax" error, and don't know of any other way around the problem. I would greatly appreciate any help on this.
Edit
Could it be you enter the command into a Python prompt? You are supposed to enter that command on the command line of your operating system shell. Which means not inside Python.
Original Answer
Like Deesha already mentioned in their comment, you must install the future package into the Python environment you wish to run PsychoPy in, e.g. via pip:
pip install future
or via conda:
conda install future
This is because newer versions of PsychoPy support both Python 2.7 and 3. The future package is used to ensure the code runs on both platforms.

editing code of a python module

Running pymatlab on my machine results in
Exception AttributeError: "'MatlabSession' object has no attribute 'engine'" in > ignored
after the command session = pymatlab.session_factory() is run.
How to fix this problem has been discussed already here:
Running MATLAB from Python
It looks like one line of code in the sessionfactory.py script in the pymatlab module has to be changed in a minor way. The problem I have is that the pymatlab module which is installed on my machine is in .egg form and it doesn't look like it is possible to change the code directly with a text editor. Any suggestions on how to do that?
Thanks
If you use easy_install, check
How do I forbid easy_install from zipping eggs?
If you prefer pip (and you probably should), check
pip: “Editable” Installs, i.e.
pip install -e pymatlab

Categories