google / import-mailbox-to-gmail

Import .mbox files into Google Workspace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem on Mac

hellomozart opened this issue · comments

Hello there,

First of all, I want to thank you for this. I hope I can get it to work, secondly I'd like to apologise as I'm sure there is nothing wrong with it, it's just that I am a total novice / newbie and don't understand simple terminal commands.

I have set everything up; step A is complete and I think working. Section B, I have all my mbox files ready and the file structure in place. I've created the test user.

Now, when I try to upload I get this error:

-bash: ./import-mailbox-to-gmail.py: No such file or directory

What could be causing that? Have I set up step A correctly?

Could you possibly give me the exact terminal command? This is currently what I am trying to use:

./import-mailbox-to-gmail.py --json /Users/jasonbradbury/Desktop/MBOXTEST/Gmail API-c1434271fb44.json --dir /Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/CVs.mbox

Thanks so much in advance!

Jason

Try to run it prefixed by python, e.g.:
python import-mailbox-to-gmail.py --json ...

Also, make sure the current directory is the directory you put import-mailbox-to-gmail.py in.

Please let me know if that doesn't work.

Thank you for your super speedy reply.

I made some progress. I actually didn't have the .py file in the current directory, so that was the problem. However, it's throwing up anothwe thing (probably another rookie error by me). Any thoughts?

Thanks again.

Hello-Mozart-MacBook-Pro:~ jasonbradbury$ python import-mailbox-to-gmail.py --json /Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/Gmail API-c1434271fb44.json --dir /Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/CVs.mbox
usage: import-mailbox-to-gmail.py [-h] [--auth_host_name AUTH_HOST_NAME]
                                  [--noauth_local_webserver]
                                  [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
                                  [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                                  --json JSON --dir DIR [--no-fix-msgid]
                                  [--noreplaceqp] [--num_retries NUM_RETRIES]
                                  [--log LOG]
                                  [--httplib2debuglevel HTTPLIB2DEBUGLEVEL]
import-mailbox-to-gmail.py: error: unrecognized arguments: API-c1434271fb44.json

Thanks Paolo!

This has now come up:

Hello-Mozart-MacBook-Pro:~ jasonbradbury$ python import-mailbox-to-gmail.py --json
usage: import-mailbox-to-gmail.py [-h] [--auth_host_name AUTH_HOST_NAME]
                                  [--noauth_local_webserver]
                                  [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
                                  [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                                  --json JSON --dir DIR [--no-fix-msgid]
                                  [--noreplaceqp] [--num_retries NUM_RETRIES]
                                  [--log LOG]
                                  [--httplib2debuglevel HTTPLIB2DEBUGLEVEL]
import-mailbox-to-gmail.py: error: argument --json: expected one argument
Hello-Mozart-MacBook-Pro:~ jasonbradbury$ *"*/Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/Gmail
> API-c1434271fb44.json*"* --dir
-bash: **/Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/Gmail
API-c1434271fb44.json**: No such file or directory
Hello-Mozart-MacBook-Pro:~ jasonbradbury$ /Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/CVs.mbox
-bash: /Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/CVs.mbox: is a directory
Hello-Mozart-MacBook-Pro:~ jasonbradbury$ 

Really appreciate the help!

@PMox your response, while correct, was garbled by GitHub. :)

The correct commandline is:
python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/Gmail API-c1434271fb44.json" --dir /Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox

Note that the dir argument here is probably incorrect. You probably need it to be:
python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/Gmail API-c1434271fb44.json" --dir /Users/jasonbradbury/Desktop/MBOXTEST

This will import the file named CVs.mbox to jason@hellomozart.co.uk's account under a "CVs" label.

Thank you Liron & Paolo. Will give this a go. Stand by!

Sorry, didn't mean to close the thread! Let me know if there looks like something is wrong from may log. Thank you!

Here's the result from another try in Terminal:

Hello-Mozart-MacBook-Pro:~ jasonbradbury$ python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Desktop/MBOXTEST/jason@h*********t.co.uk/Gmail API-c1434271fb44.json" --dir /Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk
14:54:52 INFO main@import-mailbox-to-gmail.py *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] ***
14:54:52 INFO main@import-mailbox-to-gmail.py Arguments:
14:54:52 INFO main@import-mailbox-to-gmail.py 	auth_host_name: 'localhost'
14:54:52 INFO main@import-mailbox-to-gmail.py 	auth_host_port: [8080, 8090]
14:54:52 INFO main@import-mailbox-to-gmail.py 	dir: '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk'
14:54:52 INFO main@import-mailbox-to-gmail.py 	fix_msgid: True
14:54:52 INFO main@import-mailbox-to-gmail.py 	httplib2debuglevel: 0
14:54:52 INFO main@import-mailbox-to-gmail.py 	json: '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/Gmail API-c1434271fb44.json'
14:54:52 INFO main@import-mailbox-to-gmail.py 	log: 'import-mailbox-to-gmail-36819.log'
14:54:52 INFO main@import-mailbox-to-gmail.py 	logging_level: 'INFO'
14:54:52 INFO main@import-mailbox-to-gmail.py 	noauth_local_webserver: False
14:54:52 INFO main@import-mailbox-to-gmail.py 	num_retries: 10
14:54:52 INFO main@import-mailbox-to-gmail.py 	replace_quoted_printable: True
14:54:52 INFO main@import-mailbox-to-gmail.py Processing user CVs.mbox
14:54:52 WARNING autodetect@__init__.py file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0
14:54:52 INFO _retrieve_discovery_doc@discovery.py URL being requested: GET https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest
14:54:52 INFO new_request@transport.py Attempting refresh to obtain initial access_token
14:54:52 INFO _do_refresh_request@client.py Refreshing access_token
14:54:53 INFO _do_refresh_request@client.py Failed to retrieve access token: {
  "error" : "invalid_request",
  "error_description" : "Invalid impersonation prn email address."
}
14:54:53 ERROR main@import-mailbox-to-gmail.py Can't get access token for user CVs.mbox
14:54:53 ERROR main@import-mailbox-to-gmail.py Can't process user CVs.mbox
Traceback (most recent call last):
  File "import-mailbox-to-gmail.py", line 307, in main
    service = discovery.build('gmail', 'v1', http=http)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery.py", line 228, in build
    requested_url, discovery_http, cache_discovery, cache)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery.py", line 275, in _retrieve_discovery_doc
    resp, content = http.request(actual_url)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/transport.py", line 159, in new_request
    credentials._refresh(orig_request_method)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/client.py", line 749, in _refresh
    self._do_refresh_request(http)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/client.py", line 819, in _do_refresh_request
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
HttpAccessTokenRefreshError: invalid_request: Invalid impersonation prn email address.
14:54:53 INFO main@import-mailbox-to-gmail.py *** Done importing all users from directory '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk'
14:54:53 INFO main@import-mailbox-to-gmail.py *** Import summary:
14:54:53 INFO main@import-mailbox-to-gmail.py     0 users imported with no failures
14:54:53 INFO main@import-mailbox-to-gmail.py     0 users imported with some failures
14:54:53 INFO main@import-mailbox-to-gmail.py     1 users failed
14:54:53 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with no failures
14:54:53 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with some failures
14:54:53 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) failed
14:54:53 INFO main@import-mailbox-to-gmail.py     0 messages imported successfully
14:54:53 INFO main@import-mailbox-to-gmail.py     0 messages failed

14:54:53 INFO main@import-mailbox-to-gmail.py *** Check log file import-mailbox-to-gmail-36819.log for detailed errors.
14:54:53 INFO main@import-mailbox-to-gmail.py Finished.

The issue is that you set dir to "/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk". This means that it would treat subdirectories of /Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk as the users.

You probably want to set dir to ""/Users/jasonbradbury/Desktop/MBOXTEST".

Hmmmm. I thought I did that, anyway... I changed that and got the following error:

Hello-Mozart-MacBook-Pro:~ jasonbradbury$ python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Gmail\API-c1434271fb44.json" --dir ""/Users/jasonbradbury/Desktop/MBOXTEST""
16:47:34 INFO main@import-mailbox-to-gmail.py *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] ***
16:47:34 INFO main@import-mailbox-to-gmail.py Arguments:
16:47:34 INFO main@import-mailbox-to-gmail.py 	auth_host_name: 'localhost'
16:47:34 INFO main@import-mailbox-to-gmail.py 	auth_host_port: [8080, 8090]
16:47:34 INFO main@import-mailbox-to-gmail.py 	dir: '/Users/jasonbradbury/Desktop/MBOXTEST'
16:47:34 INFO main@import-mailbox-to-gmail.py 	fix_msgid: True
16:47:34 INFO main@import-mailbox-to-gmail.py 	httplib2debuglevel: 0
16:47:34 INFO main@import-mailbox-to-gmail.py 	json: '/Users/jasonbradbury/Gmail\\API-c1434271fb44.json'
16:47:34 INFO main@import-mailbox-to-gmail.py 	log: 'import-mailbox-to-gmail-59398.log'
16:47:34 INFO main@import-mailbox-to-gmail.py 	logging_level: 'INFO'
16:47:34 INFO main@import-mailbox-to-gmail.py 	noauth_local_webserver: False
16:47:34 INFO main@import-mailbox-to-gmail.py 	num_retries: 10
16:47:34 INFO main@import-mailbox-to-gmail.py 	replace_quoted_printable: True
16:47:34 INFO main@import-mailbox-to-gmail.py Processing user jason@hellomozart.co.uk
16:47:34 ERROR main@import-mailbox-to-gmail.py Can't get access token for user jason@hellomozart.co.uk
16:47:34 ERROR main@import-mailbox-to-gmail.py Can't process user jason@hellomozart.co.uk
Traceback (most recent call last):
  File "import-mailbox-to-gmail.py", line 303, in main
    credentials = get_credentials(username)
  File "import-mailbox-to-gmail.py", line 122, in get_credentials
    scopes=SCOPES).create_delegated(username)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/service_account.py", line 219, in from_json_keyfile_name
    with open(filename, 'r') as file_obj:
IOError: [Errno 2] No such file or directory: '/Users/jasonbradbury/Gmail\\API-c1434271fb44.json'
16:47:34 INFO main@import-mailbox-to-gmail.py *** Done importing all users from directory '/Users/jasonbradbury/Desktop/MBOXTEST'
16:47:34 INFO main@import-mailbox-to-gmail.py *** Import summary:
16:47:34 INFO main@import-mailbox-to-gmail.py     0 users imported with no failures
16:47:34 INFO main@import-mailbox-to-gmail.py     0 users imported with some failures
16:47:34 INFO main@import-mailbox-to-gmail.py     1 users failed
16:47:34 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with no failures
16:47:34 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with some failures
16:47:34 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) failed
16:47:34 INFO main@import-mailbox-to-gmail.py     0 messages imported successfully
16:47:34 INFO main@import-mailbox-to-gmail.py     0 messages failed

16:47:34 INFO main@import-mailbox-to-gmail.py *** Check log file import-mailbox-to-gmail-59398.log for detailed errors.
16:47:34 INFO main@import-mailbox-to-gmail.py Finished.

In case it is useful, here is the log generated:

2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:285) *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] ***
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:286) Arguments:
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	auth_host_name: 'localhost'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	auth_host_port: [8080, 8090]
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	dir: '/Users/jasonbradbury/Desktop/MBOXTEST'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	fix_msgid: True
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	httplib2debuglevel: 0
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	json: '/Users/jasonbradbury/Gmail\\API-c1434271fb44.json'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	log: 'import-mailbox-to-gmail-59398.log'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	logging_level: 'INFO'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	noauth_local_webserver: False
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	num_retries: 10
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:288) 	replace_quoted_printable: True
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:301) Processing user jason@hellomozart.co.uk
2017-08-25T16:47:34 (+0100) 59398 ERROR main (import-mailbox-to-gmail.py:309) Can't get access token for user jason@hellomozart.co.uk
2017-08-25T16:47:34 (+0100) 59398 ERROR main (import-mailbox-to-gmail.py:347) Can't process user jason@hellomozart.co.uk
Traceback (most recent call last):
  File "import-mailbox-to-gmail.py", line 303, in main
    credentials = get_credentials(username)
  File "import-mailbox-to-gmail.py", line 122, in get_credentials
    scopes=SCOPES).create_delegated(username)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/service_account.py", line 219, in from_json_keyfile_name
    with open(filename, 'r') as file_obj:
IOError: [Errno 2] No such file or directory: '/Users/jasonbradbury/Gmail\\API-c1434271fb44.json'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:348) *** Done importing all users from directory '/Users/jasonbradbury/Desktop/MBOXTEST'
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:349) *** Import summary:
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:351)     0 users imported with no failures
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:353)     0 users imported with some failures
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:355)     1 users failed
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:357)     0 labels (mbox files) imported with no failures
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:359)     0 labels (mbox files) imported with some failures
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:361)     0 labels (mbox files) failed
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:363)     0 messages imported successfully
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:365)     0 messages failed

2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:368) *** Check log file import-mailbox-to-gmail-59398.log for detailed errors.
2017-08-25T16:47:34 (+0100) 59398 INFO main (import-mailbox-to-gmail.py:369) Finished.


Thanks for your continued support!

The issue is: No such file or directory: '/Users/jasonbradbury/Gmail\\API-c1434271fb44.json'

Try to use a slash instead of a backslash, i.e.:
python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Gmail/API-c1434271fb44.json" --dir "/Users/jasonbradbury/Desktop/MBOXTEST"

That didn't work either, well it did. It solved the initial dir problem. I think there is a few more now:

Hello-Mozart-MacBook-Pro:~ jasonbradbury$ python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Gmail API-c1434271fb44.json" --dir "/Users/jasonbradbury/Desktop/MBOXTEST"
17:08:13 INFO main@import-mailbox-to-gmail.py *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] ***
17:08:13 INFO main@import-mailbox-to-gmail.py Arguments:
17:08:13 INFO main@import-mailbox-to-gmail.py 	auth_host_name: 'localhost'
17:08:13 INFO main@import-mailbox-to-gmail.py 	auth_host_port: [8080, 8090]
17:08:13 INFO main@import-mailbox-to-gmail.py 	dir: '/Users/jasonbradbury/Desktop/MBOXTEST'
17:08:13 INFO main@import-mailbox-to-gmail.py 	fix_msgid: True
17:08:13 INFO main@import-mailbox-to-gmail.py 	httplib2debuglevel: 0
17:08:13 INFO main@import-mailbox-to-gmail.py 	json: '/Users/jasonbradbury/Gmail API-c1434271fb44.json'
17:08:13 INFO main@import-mailbox-to-gmail.py 	log: 'import-mailbox-to-gmail-63290.log'
17:08:13 INFO main@import-mailbox-to-gmail.py 	logging_level: 'INFO'
17:08:13 INFO main@import-mailbox-to-gmail.py 	noauth_local_webserver: False
17:08:13 INFO main@import-mailbox-to-gmail.py 	num_retries: 10
17:08:13 INFO main@import-mailbox-to-gmail.py 	replace_quoted_printable: True
17:08:13 INFO main@import-mailbox-to-gmail.py Processing user jason@hellomozart.co.uk
17:08:13 WARNING autodetect@__init__.py file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0
17:08:13 INFO _retrieve_discovery_doc@discovery.py URL being requested: GET https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest
17:08:13 INFO new_request@transport.py Attempting refresh to obtain initial access_token
17:08:13 INFO _do_refresh_request@client.py Refreshing access_token
17:08:14 INFO method@discovery.py URL being requested: GET https://www.googleapis.com/gmail/v1/users/jason%40hellomozart.co.uk/labels?fields=labels%28id%2Cname%29&alt=json
17:08:14 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/.DS_Store' because it doesn't have a .mbox extension
17:08:14 INFO process_mbox_files@import-mailbox-to-gmail.py Starting processing of '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox'
17:08:14 ERROR main@import-mailbox-to-gmail.py Can't process mbox files for user jason@hellomozart.co.uk
17:08:14 ERROR main@import-mailbox-to-gmail.py Can't process user jason@hellomozart.co.uk
Traceback (most recent call last):
  File "import-mailbox-to-gmail.py", line 322, in main
    result = process_mbox_files(username, service, labels)
  File "import-mailbox-to-gmail.py", line 179, in process_mbox_files
    mbox = mailbox.mbox(full_filename)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mailbox.py", line 832, in __init__
    _mboxMMDF.__init__(self, path, factory, create)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mailbox.py", line 571, in __init__
    f = open(self._path, 'rb+')
IOError: [Errno 21] Is a directory: '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox'
17:08:14 INFO main@import-mailbox-to-gmail.py *** Done importing all users from directory '/Users/jasonbradbury/Desktop/MBOXTEST'
17:08:14 INFO main@import-mailbox-to-gmail.py *** Import summary:
17:08:14 INFO main@import-mailbox-to-gmail.py     0 users imported with no failures
17:08:14 INFO main@import-mailbox-to-gmail.py     0 users imported with some failures
17:08:14 INFO main@import-mailbox-to-gmail.py     1 users failed
17:08:14 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with no failures
17:08:14 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with some failures
17:08:14 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) failed
17:08:14 INFO main@import-mailbox-to-gmail.py     0 messages imported successfully
17:08:14 INFO main@import-mailbox-to-gmail.py     0 messages failed

17:08:14 INFO main@import-mailbox-to-gmail.py *** Check log file import-mailbox-to-gmail-63290.log for detailed errors.
17:08:14 INFO main@import-mailbox-to-gmail.py Finished.

17:08:14 ERROR main@import-mailbox-to-gmail.py Can't process mbox files for user jason@hellomozart.co.uk

17:08:14 ERROR main@import-mailbox-to-gmail.py Can't process user jason@hellomozart.co.uk

IOError: [Errno 21] Is a directory: '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox'

Could it be an issue with the API set up at Google?

Any thoughts? Sorry this is so drawn out!

No problem! :)

It looks like "CVs.mbox" is a directory and not an mbox file.

Please attach the output of this command (note that uppercase/lowercase matters):
ls -laR /Users/jasonbradbury/Desktop/MBOXTEST

This should print the list of files and directories under /Users/jasonbradbury/Desktop/MBOXTEST and give us more insight about what needs to be changed, if any.

Please make sure you redact any private information shown there before posting.

Thanks!

Thanks :)

Ok, here us the output:

Last login: Sat Aug 26 16:00:52 on ttys000
Hello-Mozart-MacBook-Pro:~ jasonbradbury$ ls -laR /Users/jasonbradbury/Desktop/MBOXTEST
total 16
drwxr-xr-x   4 jasonbradbury  staff   136 25 Aug 16:46 .
drwx------+ 25 jasonbradbury  staff   850 26 Aug 15:47 ..
-rw-r--r--@  1 jasonbradbury  staff  6148 25 Aug 16:47 .DS_Store
drwxr-xr-x   4 jasonbradbury  staff   136 25 Aug 16:45 jason@hellomozart.co.uk

/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk:
total 16
drwxr-xr-x  4 jasonbradbury  staff   136 25 Aug 16:45 .
drwxr-xr-x  4 jasonbradbury  staff   136 25 Aug 16:46 ..
-rw-r--r--@ 1 jasonbradbury  staff  6148 25 Aug 16:45 .DS_Store
drwxr-xr-x@ 6 jasonbradbury  staff   204 25 Aug 12:10 CVs.mbox

/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox:
total 26024
drwxr-xr-x@ 6 jasonbradbury  staff       204 25 Aug 12:10 .
drwxr-xr-x  4 jasonbradbury  staff       136 25 Aug 16:45 ..
-rw-------@ 1 jasonbradbury  staff       123 25 Aug 12:10 .lock
-rw-r--r--@ 1 jasonbradbury  staff       330 25 Aug 12:10 Info.plist
-rw-------@ 1 jasonbradbury  staff  13308411 25 Aug 12:10 mbox
-rw-r--r--@ 1 jasonbradbury  staff      3399 25 Aug 12:10 table_of_contents

I have tried using the mbox inside CVs.mbox (which is actually the 'large' multiple GB file) but it's not recognised as a .mbox. If that makes sense.

ps - I don't think there is any private information in this? On that note... nothing I have previously posted can compromise my accounts or computer right?

Thanks!

Jason

Thanks for the details! I made a small update to try and add support for this scenario. Can you please download https://raw.githubusercontent.com/google/import-mailbox-to-gmail/master/import-mailbox-to-gmail.py and see if that works? You should still run it with:
python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Gmail API-c1434271fb44.json" --dir "/Users/jasonbradbury/Desktop/MBOXTEST"

Regarding private information - I don't see anything sensitive here (aside from your email address if you consider that sensitive). Feel free to edit your previous comments to remove it if you like.

Hey! Ok great on the private information front, I may go back and edit out my e-mail just for spams sake, but anyway...

That fix seems to have done something! It created labels within Gmail: "CVs" and "CVs.mbox" However... It didn't upload any messages.

I tested importing the box back into Mail and it works fine, so the file is not corrupt or anything.

I feel like we're getting closer though?

Details below,
Thanks!

Jason

Hello-Mozart-MacBook-Pro:~ jasonbradbury$ python import-mailbox-to-gmail.py --json "/Users/jasonbradbury/Gmail API-c1434271fb44.json" --dir "/Users/jasonbradbury/Desktop/MBOXTEST"
12:05:03 INFO main@import-mailbox-to-gmail.py *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] ***
12:05:03 INFO main@import-mailbox-to-gmail.py Arguments:
12:05:03 INFO main@import-mailbox-to-gmail.py 	auth_host_name: 'localhost'
12:05:03 INFO main@import-mailbox-to-gmail.py 	auth_host_port: [8080, 8090]
12:05:03 INFO main@import-mailbox-to-gmail.py 	dir: '/Users/jasonbradbury/Desktop/MBOXTEST'
12:05:03 INFO main@import-mailbox-to-gmail.py 	fix_msgid: True
12:05:03 INFO main@import-mailbox-to-gmail.py 	from_message: 0
12:05:03 INFO main@import-mailbox-to-gmail.py 	httplib2debuglevel: 0
12:05:03 INFO main@import-mailbox-to-gmail.py 	json: '/Users/jasonbradbury/Gmail API-c1434271fb44.json'
12:05:03 INFO main@import-mailbox-to-gmail.py 	log: 'import-mailbox-to-gmail-1414.log'
12:05:03 INFO main@import-mailbox-to-gmail.py 	logging_level: 'INFO'
12:05:03 INFO main@import-mailbox-to-gmail.py 	noauth_local_webserver: False
12:05:03 INFO main@import-mailbox-to-gmail.py 	num_retries: 10
12:05:03 INFO main@import-mailbox-to-gmail.py 	replace_quoted_printable: True
12:05:03 INFO main@import-mailbox-to-gmail.py Processing user jason@hellomozart.co.uk
12:05:03 WARNING autodetect@__init__.py file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0
12:05:03 INFO _retrieve_discovery_doc@discovery.py URL being requested: GET https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest
12:05:03 INFO new_request@transport.py Attempting refresh to obtain initial access_token
12:05:03 INFO _do_refresh_request@client.py Refreshing access_token
12:05:05 INFO method@discovery.py URL being requested: GET https://www.googleapis.com/gmail/v1/users/jason%40hellomozart.co.uk/labels?fields=labels%28id%2Cname%29&alt=json
12:05:05 INFO get_label_id_from_name@import-mailbox-to-gmail.py Label 'CVs.mbox' doesn't exist, creating it
12:05:05 INFO method@discovery.py URL being requested: POST https://www.googleapis.com/gmail/v1/users/jason%40hellomozart.co.uk/labels?alt=json
12:05:05 INFO get_label_id_from_name@import-mailbox-to-gmail.py Label 'CVs.mbox' created
12:05:05 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/.DS_Store' because it doesn't have a .mbox extension
12:05:05 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox/.lock' because it doesn't have a .mbox extension
12:05:05 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox/Info.plist' because it doesn't have a .mbox extension
12:05:05 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox/mbox' because it doesn't have a .mbox extension
12:05:05 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/jasonbradbury/Desktop/MBOXTEST/jason@hellomozart.co.uk/CVs.mbox/table_of_contents' because it doesn't have a .mbox extension
12:05:05 INFO main@import-mailbox-to-gmail.py Done importing user jason@hellomozart.co.uk. Labels: 0 succeeded, 0 with some errors, 0 failed. Messages: 0 succeeded, 0 failed.
12:05:05 INFO main@import-mailbox-to-gmail.py *** Done importing all users from directory '/Users/jasonbradbury/Desktop/MBOXTEST'
12:05:05 INFO main@import-mailbox-to-gmail.py *** Import summary:
12:05:05 INFO main@import-mailbox-to-gmail.py     1 users imported with no failures
12:05:05 INFO main@import-mailbox-to-gmail.py     0 users imported with some failures
12:05:05 INFO main@import-mailbox-to-gmail.py     0 users failed
12:05:05 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with no failures
12:05:05 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with some failures
12:05:05 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) failed
12:05:05 INFO main@import-mailbox-to-gmail.py     0 messages imported successfully
12:05:05 INFO main@import-mailbox-to-gmail.py     0 messages failed

12:05:05 INFO main@import-mailbox-to-gmail.py Finished.

I think I found the issue. Please try the new version of https://raw.githubusercontent.com/google/import-mailbox-to-gmail/master/import-mailbox-to-gmail.py with the same commandline.

Let me know if it works. :)

Ah! It worked a treat. Thank you!! Now, just to uploading my 25,000 15GB of e-mails.
Thanks again!

Great, thanks for reporting the issue, testing and confirming!