FriendCode / gittle

Pythonic Git for Humans
Other
732 stars 89 forks source link

The urlparse module is renamed to urllib.parse in Python 3 #49

Open mingalsuo opened 10 years ago

mingalsuo commented 10 years ago

Hi!

Apparently Gittle has atleast this one issue with Python 3:

ImportError: No module named 'urlparse'

My environment:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32

According to https://docs.python.org/2/library/urlparse.html:

The urlparse module is renamed to urllib.parse in Python 3.
gclsoft commented 8 years ago

Me too,help

AFAgarap commented 8 years ago

@mingalsuo was right.

@gclsoft The urlparse in Python 2.7.11 was renamed to urllib.parse in Python 3. So, if you have a code such from urlparse import urljoin, I suggest you change it to from urllib.parse import urljoin

lufeihaidao commented 8 years ago

Same problem:

>>> from gittle import Gittle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/haidao/.pyenv/versions/miniconda3-latest/lib/python3.5/site-packages/gittle/__init__.py", line 1, in <module>
    from . import utils
  File "/Users/haidao/.pyenv/versions/miniconda3-latest/lib/python3.5/site-packages/gittle/utils/__init__.py", line 1, in <module>
    from . import paths, urls, git
  File "/Users/haidao/.pyenv/versions/miniconda3-latest/lib/python3.5/site-packages/gittle/utils/urls.py", line 2, in <module>
    from urlparse import urlparse
ImportError: No module named 'urlparse'

And shell works fine.

Thulebona commented 7 years ago

open terminal nav to project or file dir and

run $ 2to3 -w projecname/ change the whole project to python3

or $ 2to3 -w file.py to change only one file

forresthopkinsa commented 7 years ago

I thought this was an issue because 2to3 didn't fix Urlparse?

On Mon, Nov 21, 2016, 6:18 AM THULEBONA HADEBE notifications@github.com wrote:

open terminal nav to project or file dir and

run $ 2to3 -w projecname/ change the whole project to python3

or $ 2to3 -w file.py to change only one file

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FriendCode/gittle/issues/49#issuecomment-261936035, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOlAQmf3FzGo8avOD2fjx1pMEaq6B3gks5rAZorgaJpZM4C2ttn .

Thulebona commented 7 years ago

2to3 works like a charm for me, haven't faced any problems using it

forresthopkinsa commented 7 years ago

In that case, this issue should absolutely be closed; it's not a Gittle bug at all.

KDIncognito commented 7 years ago

What if you wanted to install urllib.parse? I was trying to install this module through windows cmd and all I get is one error message:

Could not find a version that satisfies the requirement urllib.parse (from versions:)
No matching distribution found for urllib.parse

I tried alternative nomenclature as suggested here: http://python3porting.com/stdlib.html

hammerofdawn commented 7 years ago

Sreekrishnadutta, urllib3 has the parse module, for windows cmd:

C:\>pip install urllib3
Collecting urllib3
   Using cached urllib3-1.20-py2.py3-none-any.whl
Installing collected packes: urllib3
Successfully installed urllib3-1.20
C:\>python
...
>>>from urllib import parse

Hope that helps

coolrb commented 6 years ago

run $ 2to3 -w projecname/ change the whole project to python3 Worked like a charm for me, was struggling with geography project. It solved

dheerajmpai commented 4 years ago

Use import urllib.parse as urlparse

madux commented 4 years ago

Or simply use from urllib.parse import urlparse