how to set the environment variable `JUPYTER_PLATFORM_DIRS=1`? - python

I am running a .py file in google colab. Sometimes I can run it successfully but sometimes I get the error below. Can anyone help me fix this issue?
Traceback (most recent call last):
File "sculpt_faces.py", line 25, in <module>
from matplotlib.pyplot import cm
File "/usr/local/lib/python3.8/dist-packages/matplotlib/pyplot.py", line 2282, in <module>
switch_backend(rcParams["backend"])
File "/usr/local/lib/python3.8/dist-packages/matplotlib/pyplot.py", line 221, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.8/dist-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/usr/local/lib/python3.8/dist-packages/ipykernel/connect.py", line 18, in <module>
import jupyter_client
File "/usr/local/lib/python3.8/dist-packages/jupyter_client/__init__.py", line 4, in <module>
from .connect import *
File "/usr/local/lib/python3.8/dist-packages/jupyter_client/connect.py", line 28, in <module>
from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write
File "/usr/local/lib/python3.8/dist-packages/jupyter_core/paths.py", line 176, in <module>
deprecation(
File "/usr/local/lib/python3.8/dist-packages/jupyter_core/utils/__init__.py", line 87, in deprecation
warnings.warn(message, DeprecationWarning, stacklevel=stacklevel + 1)
DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
given by the platformdirs library. To remove this warning and
see the appropriate new directories, set the environment variable
`JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
The use of platformdirs will be the default in `jupyter_core` v6
This is the result of running "!pip install jupyter-core":
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: jupyter-core in /usr/local/lib/python3.8/dist-packages (5.1.0)
Requirement already satisfied: traitlets>=5.3 in /usr/local/lib/python3.8/dist-packages (from jupyter-core) (5.6.0)
Requirement already satisfied: platformdirs>=2.5 in /usr/local/lib/python3.8/dist-packages (from jupyter-core) (2.5.4)

This warning tells you to set the environment variable.
On Linux this can be done running
export JUPYTER_PLATFORM_DIRS=1
to set a environment variable in a terminal.
Then run
jupyter --paths
in the terminal, too. Afterwards if you run your tests/code this warning should not appear.

Related

Django - ModuleNotFoundError: No module named 'bootstrap5'

I am trying to run a django app which is made by some other developer. First I got *ModuleNotFoundError: No module named 'django_heroku'*That was solved by pip install django-heroku. Now I am getting this error.
ModuleNotFoundError: No module named 'bootstrap5'
Then I did this
pip install django-bootstrap5
It looks like it installed bootstrap5. But when I try to run again the app I am getting same error.Here is the what it shows.
(venv) D:\django\multi-vendor-shop-management-main>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Python39\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "D:\django\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "D:\django\venv\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "D:\django\venv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "D:\django\venv\lib\site-packages\django\core\management\__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "D:\django\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "D:\django\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\django\venv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "D:\django\venv\lib\site-packages\django\apps\config.py", line 228, in create
import_module(entry)
File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'bootstrap5'
When I do pip install django-bootstrap5 again, It gives me this
(venv) D:\django>pip install django-bootstrap5
Requirement already satisfied: django-bootstrap5 in d:\django\venv\lib\site-packages (21.3)
Requirement already satisfied: Django>=2.2 in d:\django\venv\lib\site-packages (from django-bootstrap5) (4.0.4)
Requirement already satisfied: beautifulsoup4>=4.8.0 in d:\django\venv\lib\site-packages (from django-bootstrap5) (4.11.1)
Requirement already satisfied: soupsieve>1.2 in d:\django\venv\lib\site-packages (from beautifulsoup4>=4.8.0->django-bootstrap5) (2.3.2.post1)
Requirement already satisfied: sqlparse>=0.2.2 in d:\django\venv\lib\site-packages (from Django>=2.2->django-bootstrap5) (0.4.2)
Requirement already satisfied: tzdata in d:\django\venv\lib\site-packages (from Django>=2.2->django-bootstrap5) (2022.1)
Requirement already satisfied: asgiref<4,>=3.4.1 in d:\django\venv\lib\site-packages (from Django>=2.2->django-bootstrap5) (3.5.1)
WARNING: You are using pip version 21.2.3; however, version 22.1 is available.
You should consider upgrading via the 'D:\django\venv\Scripts\python.exe -m pip install --upgrade pip' command.
What can I do now? I am new to django.
The preferred way to install django-bootstrap-v5 is:
$ pip install django-bootstrap-v5
According to documentation

ImportError: cannot import name '_message' from 'google.protobuf.pyext' (c:\programdata\anaconda3\lib\site-packages\google\protobuf\pyext\__init__.py)

I am trying this command(That I don't know what it does! I only following a tutorial):
tensorboard --logdir=/tmp/tensorflow/rnn_words
And get this result:
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\tensorboard.exe\__main__.py", line 5, in <module>
File "c:\programdata\anaconda3\lib\site-packages\tensorboard\main.py", line 45, in <module>
from tensorboard import default
File "c:\programdata\anaconda3\lib\site-packages\tensorboard\default.py", line 34, in <module>
import tensorflow as tf
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "c:\programdata\anaconda3\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext' (c:\programdata\anaconda3\lib\site-packages\google\protobuf\pyext\__init__.py)
What does the above command do? Why do I get this error message?
C:\Windows\system32>python --version
Python 3.7.1
C:\Windows\system32>pip install protobuf
Requirement already satisfied: protobuf in c:\programdata\anaconda3\lib\site-packages (3.6.1)
Requirement already satisfied: six>=1.9 in c:\programdata\anaconda3\lib\site-packages (from protobuf) (1.12.0)
Requirement already satisfied: setuptools in c:\programdata\anaconda3\lib\site-packages (from protobuf) (40.6.3)
if you are in mac, please try it
pip install --upgrade --force-reinstall protobuf
Works with pip install protobuf==3.14.0 with Python 3.9
You can test with the following:
# python
Python 3.9.13 (main, Aug 2 2022, 11:20:39)
>>> from google.protobuf.pyext.cpp_message import GeneratedProtocolMessageType

Pip cannot find Package when installed with --user flag

Previously I installed pip packages using sudo pip install package, but I switched to pip install --user package.
The problem is that I installed jupyter-themes using the second method, and when I try to run it the following error gets thrown.
Traceback (most recent call last):
File "/home/aswinmohanme/.local/bin/jt", line 11, in <module>
sys.exit(main())
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/jupyterthemes/__init__.py", line 260, in main
dfonts=args.defaultfonts)
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/jupyterthemes/__init__.py", line 54, in install_theme
from jupyterthemes import stylefx
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/jupyterthemes/stylefx.py", line 7, in <module>
from IPython.core.display import HTML
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/IPython/core/application.py", line 23, in <module>
from traitlets.config.application import Application, catch_config_error
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/traitlets/__init__.py", line 1, in <module>
from .traitlets import *
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/traitlets/traitlets.py", line 60, in <module>
from .utils.importstring import import_item
File "/home/aswinmohanme/.local/lib/python3.5/site-packages/traitlets/utils/importstring.py", line 8, in <module>
from ipython_genutils.py3compat import cast_bytes_py2
ImportError: No module named 'ipython_genutils'
This is the output of pip list installed
...
iniparse (0.4)
ipykernel (4.5.2)
ipython (5.3.0)
ipython-genutils (0.2.0)
ipywidgets (6.0.0)
isort (4.2.5)
...
How do I fix this.

Python DLL load failed, whilst having installed packages

I'm trying to run a python script however I get the message
ImportError: DLL load failed: %1 is geen geldige Win32-toepassing.
Full error:
Traceback (most recent call last):
File "ROC_plotting.py", line 2, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Python27\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "C:\Python27\lib\site-packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python27\lib\site-packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python27\lib\site-packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 38, in <module>
import FixTk
File "C:\Python27\lib\lib-tk\FixTk.py", line 68, in <module>
import _tkinter
ImportError: DLL load failed: %1 is geen geldige Win32-toepassing.
It seems some of these errors are concerning Matplotlib, however when I run
pip list
It seems that I do have installed matplotlib
pip list output:
cycler (0.10.0)
functools32 (3.2.3.post2)
matplotlib (2.0.2)
numpy (1.11.3+mkl)
opencv-python (2.4.13.2)
pip (9.0.1)
pyparsing (2.2.0)
python-dateutil (2.6.0)
pytz (2017.2)
scikit-learn (0.18.1)
setuptools (28.8.0)
six (1.10.0)
wheel (0.29.0)
My python version is 2.7.13, I'm running on a 64-bit Windows system.
If it's not your python version, make sure you have Microsoft Visual C++ 2008 64bit installed as it's used by matplotlib check in Control Panel > Programs

How to interpret this traceback?

I'm setting up a new development machine and installed my IDE pycharm. I installed python to C:\Program (x86)\python27. But when I start my gae server I get this traceback. What does it mean?
pydev debugger: process 7576 is connecting
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 175, in <module>
main()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 155, in main
sandbox.enable_sandbox(config)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 189, in enable_sandbox
from google.appengine.runtime import runtime
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\runtime.py", line 40, in <module>
from google.appengine.runtime import cgi
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\cgi.py", line 32, in <module>
from email import feedparser
File "C:\Program Files (x86)\python27\lib\email\feedparser.py", line 27, in <module>
from email import message
File "C:\Program Files (x86)\python27\lib\email\message.py", line 16, in <module>
import email.charset
File "C:\Program Files (x86)\python27\lib\email\charset.py", line 13, in <module>
import email.base64mime
File "C:\Program Files (x86)\python27\lib\email\base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "C:\Program Files (x86)\python27\lib\email\utils.py", line 28, in <module>
import socket
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 829, in load_module
return self.import_stub_module(fullname)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 841, in import_stub_module
__import__(fullname, {}, {})
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py", line 73, in <module>
from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE
ImportError: cannot import name RAND_egd
pydev debugger: process 2496 is connecting
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 175, in <module>
main()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 155, in main
sandbox.enable_sandbox(config)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 189, in enable_sandbox
from google.appengine.runtime import runtime
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\runtime.py", line 40, in <module>
from google.appengine.runtime import cgi
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\cgi.py", line 32, in <module>
from email import feedparser
File "C:\Program Files (x86)\python27\lib\email\feedparser.py", line 27, in <module>
from email import message
File "C:\Program Files (x86)\python27\lib\email\message.py", line 16, in <module>
import email.charset
File "C:\Program Files (x86)\python27\lib\email\charset.py", line 13, in <module>
import email.base64mime
File "C:\Program Files (x86)\python27\lib\email\base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "C:\Program Files (x86)\python27\lib\email\utils.py", line 28, in <module>
import socket
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 829, in load_module
return self.import_stub_module(fullname)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 841, in import_stub_module
__import__(fullname, {}, {})
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py", line 73, in <module>
from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE
ImportError: cannot import name RAND_egd
If I run as admin pip install PyOpenSLL then I get
C:\>pip install pyopensll
Collecting pyopensll
Could not find a version that satisfies the requirement pyopensll (from versio
ns: )
No matching distribution found for pyopensll
C:\>pip install pyOpenSSL
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in c:\progra
m files (x86)\python27\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in c:\progr
am files (x86)\python27\lib\site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in c
:\program files (x86)\python27\lib\site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\progr
am files (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): enum34 in c:\program f
iles (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in c:\program f
iles (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): idna in c:\program fil
es (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in c:\progra
m files (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in c:\progra
m files (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pycparser in c:\progra
m files (x86)\python27\lib\site-packages (from cffi>=0.8->cryptography>=0.7->pyO
penSSL)
C:\>
New:
It seems that you use LibreSSl instead of OpenSSL. See Python: Issue 21356
Check if you're using LibreSSL by running this in python-shell:
from ssl import OPENSSL_VERSION; print OPENSSL_VERSION
Old:
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py", line 73, in <module>
from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE
ImportError: cannot import name RAND_egd
is the essential for you to know. In pretty easy writing, it means:
"Google's app engine is unable to find a Name called RAND_egd in module _ssl"
Try to update all packages.
Try from _ssl Import RAND_egd from console, then put results here.
At the moment, the public Issue list doesn't have any bugs mentioning RAND_egd. I recommend filing a bug against this problem, including the stack trace and mentioning that you're seeing this on Windows 8.1. Include a link to to this stackoverflow question.
That still leaves you with an immediate problem, so consider trying this experiment: Edit google_appengine\google\appengine\dist27\socket.py and remove the reference to RAND_egd (leaving a copy of the original line commented out, or make a copy of socket.py, so that you can revert the change easily). Then see what happens. You might get lucky. And please report back.

Categories