Can't import Weka in Python - python

I've tried import weka package in Pycharm. But it got an error.
This is for Python 3.7.4 on windows 10. And I've installed java bridge and Weka successfully.
Package Version
------------------- -------
arff 0.9
javabridge 1.0.18
numpy 1.17.3
pandas 0.25.2
pip 19.3.1
python-dateutil 2.8.0
python-weka-wrapper 0.3.15
pytz 2019.3
setuptools 40.8.0
six 1.12.0
weka 1.0.6
and I type:
import weka.core
and get the error:
File "C:/Users/dell/PycharmProjects/lab2/Source.py", line 2, in <module>
import weka.core
ModuleNotFoundError: No module named 'weka.core'
So how to fix it? Thank you

weka.core is not a Python module, as the error states.
What are you trying to achieve with this import?
If you are trying to import the jvm module (eg for starting/stopping the JVM), then do something like import weka.core.jvm as jvm.

Related

ModuleNotFoundError: No module named 'torch.utils.benchmark'

I have been trying to use the torch benchmark module for profiling the code. Verified that all required imports are in place:
import torch
import torchvision
import torch.utils.benchmark
Also, these are the versions installed:
torch -> 1.4.0
torchvision -> 0.2.1
tensorflow -> 1.12.0
tensorflow-gpu -> 1.12.0
tensorboard -> 2.5.0
But I still get error: ModuleNotFoundError: No module named 'torch.utils.benchmark' while importing torch.utils.benchmark. What could be the root cause?
Have you tried to upgrade torch? I see you are using 1.4.0 but currently 1.9.0 is available.
pip install torch --upgrade
I have tested import of modules as you describe with 1.9.0 and receive no errors.

Issue with using snowflake-connector-python with Python 3.x

I've spent half a day trying to figure it out on my own but now I've run out of ideas and googling requests.
So basically what I want is to connect to our Snowflake database using snowflake-connector-python package. I was able to install the package just fine (together with all the related packages that were installed automatically) and my current pip3 list results in this:
Package Version
-------------------------- ---------
asn1crypto 1.3.0
azure-common 1.1.25
azure-core 1.6.0
azure-storage-blob 12.3.2
boto3 1.13.26
botocore 1.16.26
certifi 2020.6.20
cffi 1.14.0
chardet 3.0.4
cryptography 2.9.2
docutils 0.15.2
gitdb 4.0.5
GitPython 3.1.3
idna 2.9
isodate 0.6.0
jmespath 0.10.0
msrest 0.6.17
oauthlib 3.1.0
oscrypto 1.2.0
pip 20.1.1
pyasn1 0.2.3
pyasn1-modules 0.0.9
pycparser 2.20
pycryptodomex 3.9.8
PyJWT 1.7.1
pyOpenSSL 19.1.0
python-dateutil 2.8.1
pytz 2020.1
requests 2.23.0
requests-oauthlib 1.3.0
s3transfer 0.3.3
setuptools 47.3.1
six 1.15.0
smmap 3.0.4
snowflake-connector-python 2.2.8
urllib3 1.25.9
wheel 0.34.2
Just to be clear, it's a clean python-venv although I've tried it on the main one, too.
When running the following code in VScode:
#!/usr/bin/env python
import snowflake.connector
# Gets the version
ctx = snowflake.connector.connect(
user='user',
password='pass',
account='acc')
I'm getting this error:
AttributeError: module 'snowflake' has no attribute 'connector'
Does anyone have any idea what could be the issue here?
AttributeError: module 'snowflake' has no attribute 'connector'
Your test code is likely in a file named snowflake.py which is causing a conflict in the import (it is ending up importing itself). Rename the file to some other name and it should allow you to import the right module and run the connector functions.
Try importing 'connector' explicitly. I had the same error.
import pandas as pd
import snowflake as sf
from snowflake import connector
When I had this issue I had both the snowflake and snowflake-connector-python module installed in my environment, so it was confused on which one to use. If you're trying to use connector, just pip uninstall snowflake
If you have installed both snowflake and snowflake-connector-python, just uninstalling snowflake package will resolve the issue.
_
To list installed python packages, use command
pip list
I installed python 3.6 again.
I removed this line from code
#!/usr/bin/env python
It worked.
pip install snowflake-connector-python
Have you tried using this package instead in the jupyter notebook?
If anyone comes across this same issue and doesn't get reprieve from the above fixes, my install had a snowflake.py file saved to the site-packages folder.
This caused the 'import snowflake.connector' statement to attempt to import from the snowflake.py file instead of the snowflake folder, and of course couldn't find the connector module since the .py file isn't a package. Renaming or moving that file solved my problem.
I had a sub-folder named snowflake, but depending on how I run the script it either could or could not import the snowflake.connector.

Code is running in VS Code but not in Terminal

My python script is perfectly running in vs code, but when I run it via terminal I get the error message
"ImportError: No module named concurrent.futures"
I use a venv and a pip list shows:
Package Version
-------------- ----------
appdirs 1.4.4
attrs 19.3.0
beautifulsoup4 4.9.1
black 19.10b0
certifi 2020.4.5.2
chardet 3.0.4
click 7.1.2
futures 3.1.1
idna 2.9
pathspec 0.8.0
pip 19.2.3
regex 2020.6.8
requests 2.23.0
setuptools 41.2.0
soupsieve 2.0.1
toml 0.10.1
typed-ast 1.4.1
urllib3 1.25.9
The import in my code looks like this:
import concurrent.futures
import csv
import os
import re
import time
from datetime import date
import requests
from bs4 import BeautifulSoup
I also tried:
from futures import ThreadPoolExecutor
import concurrent.futures
installing futures not in a venv
updating futures
uninstalling futures
EDIT:
my goal is to run the script daily so I followed this tutorial Link
and I'm stuck at the point were I create a Unix executable file. When I run this file the terminal shows the error.
I figured it out my self and it was quite simple...
In the tutorial they create this file with
#!/bin/sh
Python /Users/yanissilloul/Documents/instabot-master/examples/like_hashtags_copy.py neonphotography
The solution was to activate the venv before running the .py file.
#!/bin/sh
source .venv/bin/activate
Python /Users/yanissilloul/Documents/instabot-master/examples/like_hashtags_copy.py neonphotography
Thanks to Niklas Mertsch, your question brought me there.

ModuleNotFoundError when using venv

I have just installed Python 3.8 on a Mac Catalina machine.
I have created a new virtual env using PyCharm and installed the slackclient package using PyCharm's preferences.
However, whichever way I try to run the app, I get the ModuleNotFoundError: No module named 'slackclient' error.
I have verified that it is installed in the OS terminal (zsh):
(venv) *** pip list
Package Version
------------- -------
aiohttp 3.6.2
async-timeout 3.0.1
attrs 19.3.0
chardet 3.0.4
idna 2.9
multidict 4.7.5
pip 20.0.2
setuptools 46.1.3
slackclient 2.5.0
yarl 1.4.2
(venv) *** python studiobot.py
Traceback (most recent call last):
File "studiobot.py", line 4, in <module>
from slackclient import SlackClient
ModuleNotFoundError: No module named 'slackclient'
What am I doing wrong?
Thanks in advance!
You should be using something like
from slack import WebClient
https://github.com/slackapi/python-slackclient#sending-a-message-to-slack

ImportError: No module named azure.storage.blob

I am trying to download a file from Azure onto my local device via python using the following code:
from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='account_name',
account_key='mykey')
block_blob_service.get_blob_to_path('container', 'file', 'out-test.csv')
However, when I run this code I get the following error:
ImportError: No module named azure.storage.blob
I already have installed the azure modules as seen by the snipping of the output of pip list:
C:\Users\hpfc87>pip list
Package Version
-------------------- ---------
adal 0.6.0
asn1crypto 0.24.0
azure-common 1.1.11
azure-nspkg 2.0.0
azure-storage 0.36.0
azure-storage-blob 1.1.0
azure-storage-common 1.1.0
azure-storage-file 1.1.0
azure-storage-nspkg 3.0.0
azure-storage-queue 1.1.0
I have tried following various posts about this issue like the following, but I have had no luck:
ImportError: No module named azure.storage.blob (when doing syncdb)
https://github.com/Azure/azure-storage-python/issues/262
Any advice?
Just for summary, your issue is resulted from the conflict between python 2.7 version you installed and the python version with Anaconda.
The packages you installed should to be in the python 2.7 environment. However, spyder uses the Anaconda self-brought python environment.
Command line uses system python environment which is determined by the the previous python environment variable in the path.

Categories