Usually, I perform my coding under Linux using VS Code + Anaconda but, sometimes, I have to use a Windows machine. It is easy to sync to github and keep going on Windows on the same VS Code + Anaconda.
I try to use the Visual Studio Intellicode and the default python extensions but on Windows the experience is painfully slow.
To run the code (yes, just the imports) below (the first run) takes 26.509 sec:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn import metrics
I can see that Microsoft.Python.LanguageServer is eating up to 60% CPU from my i7 notebook and more than 1500 MB RAM (sometimes with intensive I/O activity on my disk).
Anyone facing the same issues?
By the way, I'm using Python 3.7.2 and all packages installed with the default conda channels.
Related
This is an issue I have had all semester, and I have been able to ignore it up until my Final. Whenever I try to run code that shows any type of visual, be it a graph, or bar plot, or anything; it kills my kernel. This happens in both Jupyter Notebook and Jupyter Lab, but I can get visual on Google Colab. I have a Dell Inspiron 7391 2n1 with an Intel CORE i5 10th gen processor. (just in case it is my machine that has the issue.) I have uninstalled and reinstalled Anaconda and the Python packages three or four times with no luck. Below is an example of the code that kills my kernel.
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
for feature in esports_df.columns:
plt.figure(figsize=(8,4))
sns.scatterplot(data=esports_df, x=feature, y='TotalUSDPrize',
hue='TotalUSDPrize', palette='cool', legend=False)
What can I do to fix this? Because I really hope I don't have to buy a new computer
I am using python 3.8, spaCy 3.2.4, tensorflow 2.8.0, cuda 11.2, tensorflow-gpu 2.8.0. I want to import spacy, but it shows this error
import spacy
Process finished with exit code -1073740791 (0xC0000409)
Then, to fix this issue, I have to use this code
import tensorflow
import spacy
Now, it works. Although I already fixed the issue, I still want to know the reason behind the solution.
Furthermore, another question is when typing
import spacy
It shows:
Backend QtAgg is interactive backend. Turning interactive mode on.
How to always choose Qt5Agg or TkAgg instead of QtAgg? How to always turn on the interactive mode? I am using PyCharm IDE Community Edition 2020.3.5.
I am having trouble with a Jupyter script that I am using for a class at university. Useful information: I am using a MacBook Air (first time), macOS Monterey 12.0.1, M1 Apple chip, and I am working in a conda virtual environment with conda 4.11.0 and Python 3.9.7. This is the first part of the script:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from tensorflow import keras <--
import tensorflow as tf <--
from sklearn.utils import shuffle
from sklearn import preprocessing
from keras import regularizers <--
import random
from keras.utils.vis_utils import plot_model <--
import time
from IPython.display import Image
When I run it, I get this message:
The kernel appears to have died. It will restart automatically.
I tried commenting each row, and apparently, the problem is due to the ones that I highlighted with the arrow. So there is something wrong with TensorFlow. As suggested by my professor, I went on the terminal, typed ipython, then this:
In [1]: import tensorflow
zsh: illegal hardware instruction ipython
I looked it up on the internet, and I understood that there are some incompatibilities between some Python packages and the M1 Apple chip. I tried to follow this https://github.com/apple/tensorflow_macos, but when I use the command written there, this is what happens
(phdcourse) alessandroruggieri#Alessandros-MacBook-Air ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"
ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later.
This is pretty weird, considering I have macOS 12.0.1 (as said at the beginning).
To conclude, I have seen some posts about similar issues on the internet, but they all look rather confusing, so I would really appreciate an easy and clear help.
I'm trying to do inference with OpenVino Model Optimizer as detailed here.
The code I have so far runs without installing cv2, but I can't get any further because trying to import cv2 consistently throws an error. The code is:
import openvino
from openvino.inference_engine import IECore, IENetwork
import cv2
ie = IECore()
net = ie.read_network(model='saved_model.xml', weights='saved_model.bin')
This runs without
import cv2
However, anytime the cv2 import is included the following error is thrown:
File "/opt/intel/openvino_2021/python/python3.9/cv2/__init__.py", line 129, in <module>
bootstrap()
File "/opt/intel/openvino_2021/python/python3.9/cv2/__init__.py", line 112, in bootstrap
import cv2
ImportError: dlopen(/opt/intel/openvino_2021.4.752/python/python3.9/cv2/python-3/cv2.so, 2): Symbol not found: _objc_alloc_init
Referenced from: /opt/intel/openvino_2021.4.752/python/python3.9/cv2/python-3/../../../../opencv/lib/libopencv_videoio.4.5.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libobjc.A.dylib
in /opt/intel/openvino_2021.4.752/python/python3.9/cv2/python-3/../../../../opencv/lib/libopencv_videoio.4.5.dylib
I've tried downgrading cv2 to various previous versions but this did not seem to help. cv2 is needed for the cv2.dnn.blobFromImage method which I'm trying to use in this script.
Has anyone seen this problem before? Not sure how to interpret this error message.
Refer to Install and Configure Intel® Distribution of OpenVINO™ toolkit for macOS, the Intel® Distribution of OpenVINO™ version 2021.4.2 is supported on macOS version 10.15 and Python version 3.6 – 3.8.
Please ensure your Operating System is macOS 10.15 and Python version within 3.6 to 3.8.
When running from python console the following code works fine'
However when trying to use the same code in a myxxx.py it does not:
from sklearn import datasets
iris = datasets.load_iris()
print(iris.xx)
when testing sklearn it reports no failures
however when testing numpy I get 16 or so failures.
I don't know if these failures are related to my error or not.
This is on a windoes8.1 x64 machine.
So why would the code typed directly into the python console work but not from the file ( meaning it fails in spyder and python myfile.py)?
the error states something like unable to import numpy datasets. Sounds like some type of name clash or scope issue.
Thanks in advance