Pyroot: Import Error: no module named handlers - jupyter

I have been trying to build ROOT from source on my archlinux machine. I had gcc 5.3 which was not compatible with Cling so I downgraded to 4.9.3. Now the root build is successful but when I try to run a notebook in root I get the
Import Error: No module named handlers
I am using python3.5 with jupyter notebook. I tried building pyroot and then again installing root but it didn't work either. The handlers.py file does exist where it is supposed to be, the only problem is that it is not getting imported.

Related

Python Cannot Find Module Located in Sub-Directory when Importing QAxContainer from PyQt5

Python appears to be unable to locate the module QAxContainer in PyQt5. The package was installed using Conda and is present in a sub-directory of PyQt5 but cannot be located. Additional testing with pip resulted in the same error.
Ubuntu 20.04
Python 3.8.5
conda list
pyqt5 5.15.2 pypi_0 pypi
from PyQt5 import QAxContainer
ImportError: cannot import name 'QAxContainer' from 'PyQt5' (/home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/init.py)
However, qaxcontainer.py is present in /home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/uic/widget-plugins
There should be QAxContainer.pyd and QAxContainer.pyi at /home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/. If you dont have them maybe there's a problem with the package, try reinstalling PyQt5.
According to antonio2924, QAxContainer.pyd and QAxContainer.pyi should be located at /home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/. The .pyd file extension is specific to Windows. Furthermore:
The QAxContainer module is a Windows-only extension for accessing
ActiveX controls and COM objects. See, https://doc.qt.io/qt-5/qaxcontainer-module.html
I am running Ubuntu 20.04, which explains why QAxContainer is not being installed.

Python venv is giving errno 2 in visual studio code

I tried to make a virtual environment as stated in the documentation of the visual studio code. I have already installed python 3.7.3 and anaconda on the system.
I did the following and I'm using vs code version 1.34 and windows 10:
I made an empty folder and used this line of code as stated in official documentation:
py -3 -m venv .venv
I expected a folder named .venv that has scripts folder with 'activate' file in it. As i have tested this method which worked on other systems with the same configuration, But instead i get the below error message:
Error: [Errno 2]: no such file or directory : 'C:\\ProgramData\\Anaconda3\\lib\\venv\\scripts\\nt\\python.exe'
It look like installer is broken, or so...
Copy from Python 3 installation folder:
C:\Users{user}\AppData\Local\Programs\Python\Python37
Files: python.exe, python.pdb, python_d.exe, python_d.pdb, pythonw.exe & pythonw.pdb to folder: C:\ProgramData\Anaconda3\lib\venv\scripts\nt\
That's because, in the python version you are trying create virtual environment venv [ in other cases -> vitualenv] has not been installed.
environment building process fails after python global version hand over to the specific version.
you can get idea how to install vitualenv on a specific version from the link below.
Dealing with multiple python versions and pip

wkhtmltopdf not working in Eclipse and/or Spyder

Trying to export a webpage as pdf in Eclipse or Spyder, I can successfully run the following script in the Mac terminal:
import pdfkit
import wkhtmltopdf
pdfkit.from_url('http://google.com', 'out.pdf')
But, this script does not work in either Eclipse PyDev or Anaconda Spyder giving the following error:
IOError: No wkhtmltopdf executable found: ""
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
ERROR: Module: xxxx could not be imported (file: /Users/MyMac/Documents/myproject/mwe.py).
Note that I am using Python 2.7 and it seems wkhtmltopdf does not work properly in Python 3.*
Also, I have added wkhtmltopdf's folder to PYTHONPATH.
You need to add the ..\wkhtmltopdf\bin to your PYTHONPATH.
In Eclipse go to project -> properties -> PyDev-PYTHONPATH and at the register External Libraries add your source folder (full path to ..\wkhtmltopdf\bin).

Python Cryptography Error ImportError: cannot import name certificate_transparency

In cryptography which was included using pip install PyCrpto giving an error after including it in a flask application where we are running it using virtual environment have named it venv and have this dependency correctly installed in venv > lib > python2.7 > site-packages.
Below is the exact error which I am getting here.
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
But as can be seen in screenshot file cryptography.x509.certificate_transparency.py is there in file structure and even on trying python -c "from cryptography.x509 import certificate_transparency" doesn't show any warnings but here it shows error which is also marked in red.
What can be possibly wrong here ?
I came across this problem when I was building an updated Python Crypto module for shipping with Solaris (see https://www.jmcpdotcom.com/blog/2018-02-21-im-embarrassed-to-admit-it/).
The root cause in your case appears to be that you haven't installed it in the right place. While you claim above that it's "correctly installed" in venv > lib > python2.7 > site-packages the screenshot shows that it is in fact in venv/lib/cryptography. If you move the cryptography dir down a level I would expect that your import would work.

Issue with dependencies running python file on another PC

I have a python file running perfectly in the IDE.
I want to run it on a different PC without any IDE.
I run the program from the command line: python program.py
Error message: File "program.py", line 8, in
from mpl_finance import candlestick_ohlc
ModuleNotFoundError: No module named 'mpl_finance'
When trying: pip install mpl_finance (or pip install mpl_toolkits)
I get the message: No matching distribution found for mpl_finance (or mpl_toolkits)
There also seems to be a problem with matplotlib backend.
Looking for a solution please.
After many failed paths, here's what worked:
matplotlib.finance is deprecated and it is now mpl_finance.
Create 2 files named mpl_finance.py and setup.py and get their contents from here.
Then from the command-line: python setup.py install
Fixing the backend (this can save you a few days):
If the backend of matplotlib was set in a file original PC (and not in the code). Then you need to do the same on the second PC.
Windows Path: C:\Program Files\Python36\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
Change (probably line 38) to this: backend : Qt5Agg