Trouble installing geopy with Python 3.2 - python

I am trying to install a module on python 3.2 but am unable to. I am using Windows 7. I need to have the module installed only on Python 3.2, so solutions that work for other versions of Python won't be helpful to me (I had no problem installing modules in Python 2.7 or 3.3, 3,4) I got rid of all my other versions of python, because I thought that might be the problem.
I have tried both using pip install, and to manually install the package and neither works. At first glance it looks like I am installing setuptools and pip correctly. Here is the output I get when I try to install pip
Installed c:\python32\lib\site-packages\setuptools-7.0-py3.2.egg
Processing dependencies for setuptools==7.0
Finished processing dependencies for setuptools==7.0
PS C:\> python32 .\get-pip.py
Requirement already up-to-date: pip in c:\python32\lib\site-packages
Cleaning up...
PS C:\> pip install geopy
It looks fine, right?
Then when I try to use by entering pip install geopy Here is the output I get
pip: the termpipis not recognized as the name of a cmdlet, function or operable program etc. I made sure that python 3.2 was specified in the path environments, and uninstalled all other versions of pythons. I don't know what else I can do?
I also tried to manually install geopy. I went to the geopy page on github and pressed on "Download ZIP". I then extracted the folder to lib/site-packages directory in python32. When I tried to install using the setup.py (python32 setup.py install) Here is the error message that I got. I am not sure what this error message means
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from geopy import __version__ as version
File "C:\python32\lib\site-packages\geopy-master\geopy\__init__.py", line 10, in <module>
from geopy.location import Location
File "C:\python32\lib\site-packages\geopy-master\geopy\location.py", line 21
def __init__(self, address=u"", point=None, raw=None):

Update: GeoPy 1.6.0 introduced support for Python 3.2, so update it and it should install and work.
Old answer:
This is a bug with geopy, and/or it doesn't support Python 3.2. With this Python release, strings cannot be in the form u"the string", since it is a SyntaxError. This was fixed with PEP-414 for Python 3.3.
While you can install the package, a quick fix for geopy is to edit the installed files to remove the u in several module files, such as "C:\python32\lib\site-packages\geopy-master\geopy\location.py" (as shown in your question).
For example:
Change address=u"" to address=""
Change signature_method=u"HMAC-SHA1" to signature_method="HMAC-SHA1"
Also watch out for single quote changes, e.g. u'the string'
etc.

Related

Using PyCharm-requirements.txt in virtual environment- gives an error- 'pip' has no attribute 'main'

I am working in windows7. and have pycharm installed along with anaconda spyder. I have been working in anaconda spyder for very long but now I want to use pycharm as it is better and easier to create projects.
so I created a new virtual environment and started a new project. Now when I try to specify my package installs via requirements.txt I get this error.
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition
2017.2.4\helpers\packaging_tool.py", line 192, in main
retcode = do_install(pkgs)
File "C:\Program Files\JetBrains\PyCharm Community Edition
2017.2.4\helpers\packaging_tool.py", line 109, in do_install
return pip.main(['install'] + pkgs)
AttributeError: module 'pip' has no attribute 'main'
I need help in fixing this. Nothing online has worked and I dont know where the problem is. I am using pip version of 10.
Should I uninstall my anaconda python. is it possible that it is interfering with pycharm?
Thanks
pip.main is no longer supported, and, as of 10.0, was removed. (See this documentation on what to do instead, but that probably isn't directly relevant to you—you're just trying to use PyCharm, not write your own replacement for PyCharm…)
Anyway, any graphical package manager that was built around calling pip.main, as PyCharm's used to be, breaks with 10.0. IIRC, PyCharm changed its code to handle this before 10.0 even went live. However, you're using an old version of PyCharm, which doesn't have those changes.
The obvious solution is to update PyCharm.
If you don't have any reason to use an old version, just get the latest version (as of today, 2018.1.4) by auto-updating, or by downloading it from the main Download page.
If you need to stick with an old version for some reason, get the latest 2017.2 version (as of today, 2017.2.7) from the Previous Releases page. This should be essentially the same as the version you have, but with critical fixes backported (which hopefully includes working with pip 10, although I haven't tested that).
The other option is to downgrade pip to a pre-10.0 version.
You can specify a version as just <10. If you want to specify one explicitly, I think 9.0.3 should be the last-ever 9.x version, but, to be safe, check the version history.
I don't know if downgrading pip with pip is supposed to work, but it actually did seem to work when I tried it on a test environment:
python3 -m pip install --force-reinstall 'pip<10'
If not, you can uninstall it and reinstall it:
python -m pip uninstall pip
python -m ensurepip
python -m pip install -U 'pip<10'

Installing python bottle framework for python 3.6.1 version instead of python 2.7.1 version?

I am currently working on a mongo db assignment using pymongo, as part of it we need to install python bottle framework. I have installed bottle on the Mac using the below command:
$ pip install bottle
got the below message returned.
Requirement already satisfied: bottle in /Library/Python/2.7/site-packages
when I run a program from terminal which uses bottle, it throws the below error:
$ python hello_m101p.py
Traceback (most recent call last):
File "hello_m101p.py", line 2, in <module>
import bottle
ModuleNotFoundError: No module named 'bottle'
I noted that i also have python 3.6.4 version installed on my system. I need bottle framework to be saved or installed for this version instead of the default 2.7 version. After a quick lookup around stack overflow, I tried the below command from one the suggested answers. I get the command not found error:
sudo pip-3.6.4 install bottle
sudo: pip-3.6.4: command not found
Any help to correct this error ? I am not sure how to address this. Please let me know if the question is unclear or need more context.
The default name for pip for Python version X.Y.Z is not pip-X.Y.Z, but pipX.Y. Some linux distros use different names for their versions, but I believe on Mac, both the python.org Python installer and the Homebrew python package (and you probably have one of those two) use the default names, at least as of 2018.
If you only have one 3.Y.Z, it will probably also be available as pip3, which is convenient.
If you've got different names and are hopelessly confused, but you do know how to run your Python 3 itself, you can always use the -m flag to run pip.
Also, most Mac Python installs don't need sudo. If you don't know whether you do, try it without first. If you get a bunch of permissions errors, then you do need sudo after all, but otherwise, don't use it.
So, what you want is probably any of these:
pip3.6 install bottle
pip3 install bottle
python3 -m pip install bottle

Python pip install gives “Command ”python setup.py egg_info“ failed with error code 1”

Edit: Yes I know this question already exists, except my question is a bit different and none of the solutions fixed it.
I do most of my Python stuff when I'm at work and not on my personal machine, but I decided to install it on my personal computer as well. I fresh installed python 3.6.1, and created a virtual environment with virtualenv. Then within the virtualenv I tried to pip install urllib (or any module) and I received the error:
(pdbot) C:\Users\user\Documents\pdbot>pip install urllib
Collecting urllib
Using cached urllib-1.21.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\user\AppData\Local\Temp\pip-build-50tn0wlb\urllib\setup.py", line 191
s.connect((base64.b64decode(rip), 017620))
^
SyntaxError: invalid token
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-50tn0wlb\urllib\
I read elsewhere that this error had something to do with setuptools not being properly installed. So I ran this to attempt to fix the issue:
easy_install -U setuptools
I ended up receiving an even weirder error next:
(pdbot) C:\Users\zeke\Documents\pdbot>easy_install -U setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Downloading https://pypi.python.org/packages/a9/23/720c7558ba6ad3e0f5ad01e0d6ea2288b486da32f053c73e259f7c392042/setuptools-36.0.1.zip#md5=430eb106788183eefe9f444a300007f0
Best match: setuptools 36.0.1
Processing setuptools-36.0.1.zip
Writing C:\Users\zeke\AppData\Local\Temp\easy_install-jhg1val_\setuptools-36.0.1\setup.cfg
Running setuptools-36.0.1\setup.py -q bdist_egg --dist-dir C:\Users\zeke\AppData\Local\Temp\easy_install-jhg1val_\setuptools-36.0.1\egg-dist-tmp-8apak7kn
warning: no files found matching '*' under directory 'setuptools\_vendor'
Copying setuptools-36.0.1-py3.6.egg to c:\users\zeke\documents\pdbot\lib\site-packages
Adding setuptools 36.0.1 to easy-install.pth file
Installing easy_install-script.py script to c:\users\zeke\documents\pdbot\Scripts
Installing easy_install.exe script to c:\users\zeke\documents\pdbot\Scripts
error: [WinError 5] Access is denied: 'c:\\users\\zeke\\documents\\pdbot\\Scripts\\easy_install.exe'
This looks like a permissions error, but I ran these both in an administrator command prompt (Windows 10) and got the same result. I am the only user on this computer and I have all admin permissions. Is this virtualenv causing an issue? How do I remedy it?
EDIT: I was able to fix the permissions issue by leveraging the python executable like so:
python -m easy_install -U setuptools
But it didn't fix the python setup.py egg_info issue. I still get this error message when trying to pip install anything:
Command "python setup.py egg_info" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-50tn0wlb\urllib\
I have tried both python -m pip install urllib and pip install urllib and neither work.
I had the same problem when trying to install urllib, but after doing a pip search urllib, I discovered that the problem was due to the version of urllib. From the search:
$ pip search urllib
...
> urllib5 (5.0.0) - Just increment the number and create a new lib. Never fix the original one.
At the end, a simple
pip install urllib5
within an elevated shell solved it.
Your problem has to do with permissions. The related/similar tools setup_tools, easy_install, and pip all tend to set a default set of permissions on files and folders they try to create in the package installation folder(s), rather than trying to match access permissions of the location they're installing in.
On Linux systems, where files and folders individually have permissions, this is frequently bypassed with the sudo command. On Windows, the equivalent is to run the installer as an Administrator. Since you're in the console, you have to open a console with Administrator privileges to run the pip command in.
Notable under Windows, the modules installed with pip from an Administrator console are still accessible to all users of the system that have the proper path in the PYTHONPATH system environment variable. Under Linux however, the problem is exacerbated by the fact that the files themselves may not be created with read and execute access for other users and may need to have their permissions manually modified after installation.
WARNING: urllib vs urllib2 vs urllibx
Both other answers claim that the problem is you're not specifying the correct "version" of the module in the call to pip. Neither is correct, as the error clearly indicates an installation folder access permissions violation causing the failure, but they also incorrectly recommended VERY unsafe behavior.
pip install urllib != pip install urllib5 these are two completely different packages.
The documentation for pip (https://packaging.python.org/tutorials/installing-packages/#id17) clearly says the way to specify a module version explicitly is pip install 'urllib==5'.
As part of how the package management engine implemented by pip works, running the command pip install urllib will always try to use the latest version of the urllib package, so you shouldn't need to specify the version unless you have some reason that you need a very specific version of the module.
There are two points to make in order to answer your question:
1. You are lucky you did not install that package!
The package you were trying to install was a maliciously created python package that was designed to look like a real package (in this case urllib3). If you had installed it, the package would have operated as normal except it would have sent some basic information about the system on which you installed the package to a URL (you can see more details on this here). You can read more about this fake package at either of the following links:
https://app.threatconnect.com/auth/incident/incident.xhtml?incident=5256822&owner=Common%20Community (you can sign up for a free account to view this one)
http://www.nbu.gov.sk/skcsirt-sa-20170909-pypi/index.html
Sending basic information about your systems to an unknown source isn't the worst thing you could do, but is certainly something you want to avoid when possible.
2. To properly install a package...
Specifically urllib:
To install urllib, you need to specify the version of the package you would like to install. For example, pip install urllib3.
Any package in general:
As #Elisabete Coelho suggested, you can use the pip search <package-name> feature to view the available packages. This is not perfect, however, as it may list malicious libraries like the one you were trying to install. A good guideline is that you should follow the installation instructions in a package's documentation closely to avoid any unforeseen issues. This is just an unfortunate necessity of living in a world where people make pretend python packages.

Python - How can I install xlutils?

I am using Python 2.5 (and need to stay with that) and have already downloaded xlrd 0.8.0 and xlwt 0.7.2, and they both seem to be working OK.
I will be needing to read from and write to Excel spreadsheets, and so believe I will need to add xlutils as well. The problem is, I can't install it so far.
I have pip and tried the simple:
pip install xlutils
That ran and downloaded xlutils, but got hung up with:
Downloading/unpacking xlutils
Downloading xlutils-1.6.0.tar.gz (54Kb): 54Kb downloaded
Running setup.py egg_info for package xlutils
Downloading/unpacking xlrd>=0.7.2 (from xlutils)
Downloading xlrd-0.9.2.tar.gz (167Kb): 167Kb downloaded
Running setup.py egg_info for package xlrd
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Python25\Lib\site-packages\xlutils-1.6.0\build\xlrd\setup.py", li
ne 8, in <module>
raise Exception("This version of xlrd requires Python 2.6 or above. "
Exception: This version of xlrd requires Python 2.6 or above. For older versions of Python, you can use the 0.8 series.
... [snipping some]
----------------------------------------
Command python setup.py egg_info failed with error code 1 in C:\Python25\Lib\sit
e-packages\xlutils-1.6.0\build\xlrd
So then I figured it was trying to download a newer xlrd (which I can't use with Python 2.5) and since I already have xlrd installed, it breaks on that.
I then tried to just download xlutils from https://pypi.python.org/pypi/xlutils, and then unzipped it with 7zip, put the xlutils folder under Python25>Lib>site-packages, cd'd there, and did:
python setup.py install
but that gives me this error in the cmd window:
C:\Python25\Lib\site-packages\xlutils-1.6.0>python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup
ImportError: No module named setuptools
So how can I install this?
First of all, you do not need xlutils just to read and write Excel files. You can read them with xlrd and write them with xlwt and provide your own "glue" in the Python code that you write yourself.
That said, xlutils does provide features that make some things more convenient than writing them for yourself (that is the point of its existence). So the second part of my answer is: You do not need to "install" xlutils per se. You can just unpack it and put the xlutils directory into site-packages and be off and running. This is true for pretty much every pure-Python package, as far as I know. (Some other packages are partially written in C (or sometimes other languages) and these often require specific installation steps.) So why do pure-Python packages provide a setup.py script? Usually to run tests or to build .pyc files, both of which are optional.
xlutils 1.4.1 is compatible with python 2.5. So this should work:
pip install xlutils==1.4.1
Try install python-setuptools package.
In Debian:
sudo apt-get install python-setuptools
For 3.x version
sudo apt-get install python3-setuptools
pip3 install xlutils
Using pip3 instead of pip solved it for me.

Is MathDOM 0.8 compatible with Python 2.7?

I want to convert AsciiMath to MathML. I just want to get the XML content but I need not to display on browser.
So, I have installed MathDOM 0.8, lxml 2.3, pyparsing 1.5.6. I have not installed PyXML because MathDOM uses PyXML or lxml, and pyparsing.
I then run three examples in MathDOM directory such as dom.py, infix.py and ldom.python.
dom.py and infix.py output an error: ImportError: No module named Element
Otherwise, ldom.py outputs other error: AttributeError: 'NoneType' object has no attribute 'setParseAction'
I have also tried to install PyXML but I could not run the examples, too.
Please help me.
Thanks.
I ran into exactly the same issue — many thanks to you and Jon Olav Vik for pointing me in the direction of a solution.
I'm using virtualenv and pip, so installing the old version through the usual mechanisms was actually preferable to the manual bundling Jon describes. Unfortunately, just doing pip install pyparsing==1.4.2 doesn't work, but pointing pip at SourceForge certainly does. In one line:
$ pip install http://downloads.sourceforge.net/project/pyparsing/pyparsing/pyparsing-1.4.2/pyparsing-1.4.2.tar.gz
MathDOM 0.8 (which installs module mathml) works only with the older pyparsing 1.4.2.
Here's a way to override pyparsing with the older version, affecting mathml only. Tested on Python 2.7 on Windows 7:
Download and extract MathDOM 0.8.
Download revision 68 of pyparsing.py (version 1.4.2 according to the SVN commit messages, though there are no tags in the repository) and save it in the mathdom-0.8/mathml folder that you extracted. This will take precedence over the installed pyparsing, but only for the mathml package.
Navigate to mathdom-0.8/ and install (e.g. python setup.py install or pip install ., perhaps appending --prefix=$HOME/usr or somesuch).
Test with python -c "from mathml import termparser"; it should succeed where it previously failed with AttributeError: 'NoneType' object has no attribute 'setParseAction'.
You can also verify that python -c "from mathml import pyparsing; print pyparsing.__version__" prints 1.4.2, whereas python -c "import pyparsing; print pyparsing.__version__" prints 1.5.6.
Hope this helps!
I happened to face pyparsing missing for matplotlib on python 2.7 in windows 7. I downloaded the zip version from https://pypi.python.org/pypi/pyparsing/1.5.7 , extracted, Opened a command prompt inside the extracted directory where I have the setup.py and ran python setup.py install It worked! The only additional thing was I had to add python location to my path variable. Like this: set path=%path%+;C:\python27 before executing the previous command.

Categories