--Lorsque j'ai essayé de déployer GCP Cloud Functions localement, cela ne fonctionnait pas. ――Après essais et erreurs, tout s'est bien passé, alors notez le processus de vérification et la solution. «J'espère que cela aidera ceux qui sont dépendants d'erreurs similaires.
[usr_id@PC_NAME] ~/Documents/project/function_name
% gcloud functions deploy function-name --region asia-northeast1 --runtime python37 --trigger-topic topic-name #Déployer la commande
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: gcloud crashed (UnicodeEncodeError): 'ascii' codec can't encode character u'\u281b' in position 58: ordinal not in range(128)
If you would like to report this issue, please run the following command:
gcloud feedback
To check gcloud for common problems, please run the following command:
gcloud info --run-diagnostics
[usr_id@PC_NAME] ~/Documents/project/function_name
% gcloud info --run-diagnostics #Détails de l'erreur
Network diagnostic detects and fixes local network connection issues.
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Users/usr_id/.pyenv/versions/2.7.0/lib/python2.7/threading.py", line 530, in __bootstrap_inner
self.run()
File "/Users/usr_id/.pyenv/versions/2.7.0/lib/python2.7/threading.py", line 483, in run
self.__target(*self.__args, **self.__kwargs)
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/progress_tracker.py", line 164, in Ticker
if self.Tick():
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/progress_tracker.py", line 235, in Tick
self._Print(self._GetSuffix())
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/progress_tracker.py", line 261, in _Print
self._console_output.UpdateConsole()
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/multiline.py", line 154, in UpdateConsole
self._UpdateConsole()
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/multiline.py", line 168, in _UpdateConsole
self._messages[self._last_print_index].Print()
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/multiline.py", line 281, in Print
self._WriteLine(line)
File "/Users/usr_id/google-cloud-sdk/lib/googlecloudsdk/core/console/multiline.py", line 331, in _WriteLine
self._stream.write(self._level * INDENTATION_WIDTH * ' ' + line)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u281b' in position 30: ordinal not in range(128)
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).
Property diagnostic detects issues that may be caused by properties.
Checking hidden properties...done.
Hidden Property Check passed.
Property diagnostic passed (1/1 checks passed).
gcloud crashed (UnicodeEncodeError): 'ascii' codec can't encode character u'\u281b' in position 58: ordinal not in range(128)
--Python utilisé dans le SDK --python2.7 mis dans pyenv
[usr_id@PC_NAME] ~/Documents/project/function-name
% echo $CLOUDSDK_PYTHON
/Users/usr_id/.pyenv/versions/2.7.0/bin/python
% $CLOUDSDK_PYTHON
Python 2.7 (r27:82500, Nov 1 2019, 14:21:44)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'shift-jis'
>>>
[usr_id@PC_NAME] ~/.pyenv/versions/2.7.0/lib/python2.7/site-packages
% pwd
/Users/usr_id/.pyenv/versions/2.7.0/lib/python2.7/site-packages
[usr_id@PC_NAME] ~/.pyenv/versions/2.7.0/lib/python2.7/site-packages
% cat sitecustomize.py
import sys
sys.setdefaultencoding('utf-8')
[usr_id@PC_NAME] ~/.pyenv/versions/2.7.0/lib/python2.7/site-packages
% $CLOUDSDK_PYTHON
Python 2.7 (r27:82500, Nov 1 2019, 14:21:44)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
>>>
shift-jis
, qui ne correspond pas au contenu de l'erreur'ascii 'le codec ne peut pas encoder
.$ CLOUDSDK_PYTHON
, mais le python qui est réellement utilisé dans le déploiement est différent ...?[usr_id@PC_NAME] /Library/Python/2.7/site-packages
% echo $CLOUDSDK_PYTHON
/usr/bin/python2.7
[usr_id@PC_NAME] /Library/Python/2.7/site-packages
% pwd
/Library/Python/2.7/site-packages
[usr_id@PC_NAME] /Library/Python/2.7/site-packages
% $CLOUDSDK_PYTHON
Python 2.7.16 (default, Oct 16 2019, 00:34:56)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
>>>
―― Cela l'a résolu!
[usr_id@PC_NAME] ~/Documents/project/function-name
% gcloud functions deploy function-name --region asia-northeast1 --runtime python37 --trigger-topic topicname
Deploying function (may take a while - up to 2 minutes)...done.
availableMemoryMb: 256
entryPoint: function-name
eventTrigger:
eventType: google.pubsub.topic.publish
failurePolicy: {}
resource: projects/project-name/topics/topicname
service: pubsub.googleapis.com
ingressSettings: ALLOW_ALL
labels:
deployment-tool: cli-gcloud
name: projects/project-name/locations/asia-northeast1/functions/function-name
runtime: python37
serviceAccountEmail: [email protected]
sourceUploadUrl: hogehoge
status: ACTIVE
timeout: 60s
updateTime: '2020-02-06T02:15:16Z'
versionId: '19'
--Il semble qu'il ne peut pas être affiché si la sortie de symbole à l'indicateur après l'exécution de cli est ascii. --ʻU '\ u281b'` → ⠛ C'était ce symbole ―― ↓
$ CLOUDSDK_PYTHON
, je me demande si ce python sera utilisé, mais la valeur par défaut de Mac est utilisée. J'aurais dû passer le PATH aussi ...
--Il n'est peut-être pas bon de trop compter sur pyenvRecommended Posts