use vtk in pycharm ,python3.9.2 conda - vtk

I want to run the python+vtk in pycharm by using conda,there are some errors in my computer,please help me.
import vtkmodules.all as vtk
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
File "D:\main.py", line 3, in <module>
import vtkmodules.all as vtk
File "C:\Users\86136\AppData\Roaming\Python\Python39\site-packages\vtkmodules\all.py", line 7, in <module>
from .vtkCommonCore import *
ImportError: DLL load failed while importing vtkCommonCore: 找不到指定的模块。

Unfortunately, I frequently met the similar problem for Qt, and I can not find a good solution. Usually, I create a new conda environment or re-install conda.

Related

Having problems installing python-docx

>>> import docx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\users\kevin\mu_code\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "c:\users\kevin\mu_code\docx\api.py", line 14, in <module>
from docx.package import Package
File "c:\users\kevin\mu_code\docx\package.py", line 9, in <module>
from docx.opc.package import OpcPackage
File "c:\users\kevin\mu_code\docx\opc\package.py", line 9, in <module>
from docx.opc.part import PartFactory
File "c:\users\kevin\mu_code\docx\opc\part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "c:\users\kevin\mu_code\docx\opc\oxml.py", line 12, in <module>
from lxml import etree
ImportError: cannot import name 'etree'
I have python-docx 0.8.10 and lxml 4.5.0, windows 10. I tried googling already but I'm not sure if I followed the suggestions correctly or if it's applicable in my case (lxml problems). I haven't had any problems installing other modules using "pip install" so I'm stuck and don't know how to proceed from here.
Check this,
Use pip install, to install the docx library and if you have already install it successfully then have a look into its dependencies. I think it is because of the incompatibility with its dependencies that is why you are getting the error.
pip install python-docx
Dependencies
Python 2.6, 2.7, 3.3, or 3.4
lxml >= 2.3.2
I don't know whether this may be an appropriate solution for you. But this is what I generally follow. Just install Anaconda in your system and an environment according to your needs. For your case create an environment for Python 3.4 using the following command
conda create --name py34 python=3.4
You then install libraries according to your needs in the respective environment. Now you can work into each environment without interfering with the libraries of the other environment. To use anaconda kindly follow Anaconda cheatsheet.
Kindly refer to the link. Hope this helps you.
This is almost certainly a problem with the lxml install. python-docx works with all versions of Python >= 2.6.
Instead of import docx, try from lxml import etree. If this produces the same error message, you know you've narrowed it down.
lxml depends on a couple of C libraries, lib2xml and libxslt if I remember correctly. These are sometimes tricky to install. In any case, you'll find solutions to those problems by searching on "lxml install windows" or similar.
Once from lxml import etree works without error I think you'll find import docx does too.

ModuleNotFoundError: No module named 'pystruct.models.utils'

i wants to use linearchain crf using pystruct library in pycharm, but i found this error
File "C:/Users/admin/PycharmProjects/sequential-rumour-detection/run.linearcrf.py", line 25, in
from pystruct.models import ChainCRF
File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pystruct\models__init__.py", line 2, in
from .crf import CRF
File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pystruct\models\crf.py", line 5, in
from .utils import loss_augment_unaries
ModuleNotFoundError: No module named 'pystruct.models.utils'
Please suggest me solution to solve this error. my python version is 3.7
The issue is because you haven't installed pystruct. You need to install pystruct.
You can check this link to install pystruct

Why on earth can I not import nashpy into my Python library?

import nashpy as nash
I'm attempting to import nashpy but I keep receiving the error message below despite already pip installing nashy:
File "G:\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
>>>
Could you help me understand it?
If you look at the line which is causing the error, you'll see this:
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
This line comment states the dependency as numpy+mkl (numpy with Intel Math Kernel Library). This means that you've installed the numpy by pip, but the scipy was installed by precompiled archive, which expects numpy+mkl.
This problem can be easy solved by installation for numpy+mkl from whl file from here.

Keras import loading neural network

The script normally works on a local machine, but it also fails when it is uploaded to the server. The program falls on the line:
from keras.models import model_from_json
All versions of libraries on a laptop and server are the same. Python 3.6.5, Keras 2.2.4, Tensorflow 1.5.0, Numpy 1.14.3
Error message:
(base) C:\classX5>python app.py
Using TensorFlow backend.
Traceback (most recent call last):
File "app.py", line 8, in <module>
from keras.models import model_from_json
File "C:\Anaconda3\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Anaconda3\lib\site-packages\keras\utils\__init__.py", line 27, in <mo
dule>
from .multi_gpu_utils import multi_gpu_model
File "C:\Anaconda3\lib\site-packages\keras\utils\multi_gpu_utils.py", line 7,
in <module>
from ..layers.merge import concatenate
File "C:\Anaconda3\lib\site-packages\keras\layers\__init__.py", line 4, in <mo
dule>
from ..engine.base_layer import Layer
File "C:\Anaconda3\lib\site-packages\keras\engine\__init__.py", line 8, in <mo
dule>
from .training import Model
File "C:\Anaconda3\lib\site-packages\keras\engine\training.py", line 21, in <m
odule>
from . import training_arrays
File "C:\Anaconda3\lib\site-packages\keras\engine\training_arrays.py", line 8,
in <module>
from scipy.sparse import issparse
File "C:\Anaconda3\lib\site-packages\scipy\__init__.py", line 119, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "C:\Anaconda3\lib\site-packages\scipy\_lib\_ccallback.py", line 1, in <mo
dule>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c'
All versions of libraries on a laptop and server are the same. Python
3.6.5, Keras 2.2.4, Tensorflow 1.5.0, Numpy 1.14.3
But NOT the scipy package.
Just uninstall (pip3 uninstall scipy) and reinstall scipy package. It solved the problem for many people.
Posting my same answer here I posted on the linked question:
This is likely an issue with the SciPy Python module compatibility you have installed in your site-packages folder and the OS architecture you're running it on.
After digging in, to give the full background on this, first of all SciPy relies on having NumPy already installed. The SciPy wheel's setup.py file uses NumPy functionality to configure and install the wheel.
SciPy setup.py:
...
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
Secondly, when just trying to use the wheel, if you run into this error, you can see after inspecting the wheel's files that the reason is the binary wheels have a naming convention where the shared object file, here it's called _ccallback_c.so, is instead named based on the architecture that the binary wheel supports. When trying to import the shared object by file name in /_lib/_ccallback.py it can't find it, hence this error (line 1 in /_lib/_ccallback.py) because, instead of being named _ccallback_c.so it's called _ccallback_c.cpython-36m-x86_64-linux-gnu.so or another architecture variation:
from . import _ccallback_c
These file names may be an artifact of having not run the NumPy setup process yet or something related to Cython, that I'm not quite sure about. But the easiest fix is to change the .whl extension to .zip and rename all those relevant .so files to not contain the architecture snippet. Then change .zip -> .whl and it should be good to go.

Import Seaborn Error - Numpy_MKL (Python Script)

I coded in jupyter-notebook, fetching data from mysqlserver and then downloaded it as a python script because I want to implement it in my website using cronjob. So when I run the Python script, I'm getting this error:
import seaborn as sns
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\palettes.py", line 12, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\seaborn\utils.py", line 7, in <module>
from scipy import stats
File "C:\Users\Debadri\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
I tried to install numpy+mkl .whl file from this link: Numpy+MKL, this (numpy‑1.15.1+mkl‑cp37‑cp37m‑win_amd64.whl) package, but it showed, not supported when I tried to install it.
The following solution worked out:
Solution:
If you are using windows make sure you install numpy+mkl instead of just numpy.
If you have already installed scipy and numpy, uninstall then using "pip uninstall scipy" and "pip uninstall numpy"
Now download scipy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy (appropriate version for your python and system)
and install using "pip install scipy‑1.1.0‑cp36‑cp36m‑win_amd64.whl" (Please install from the list according to your system config)
Your numpy and Scipy both should work now.
These binaries by Christoph Gohlke makes it very easy to install python packages on windows. But make sure you download all the dependent packages from there.
Reference: 4th answer of this question ImportError: cannot import name NUMPY_MKL

Resources