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
Related
I recently acquired a NAS and trying to run a python script. Issue is that I cannot run the python script as a normal user (python script.py). Python is only running if I run as a sudo user (e.g., sudo python script.py)
When I run as a normal user, it does not detect the libraries such as pandas. But I do not want to run as a sudo because sudo would required a password.
I think the issue comes from the pip installation.
Do you know what could be the issue?
Greatly appreciate
In the terminal, when I run "pip list" as a normal user, it states 'ModuleNotFoundError: No module named 'pip._internal'
`
user#NAS:~$ pip list
Traceback (most recent call last):
File "/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'
but when I run as a sudo:
user#NAS:~$ sudo pip list
Password:
Package Version
certifi 2022.6.15
charset-normalizer 2.1.1
idna 3.3
numpy 1.23.2
pandas 1.5.1
pip 22.3.1
pyasn1 0.4.5
pysmb 1.2.2
python-dateutil 2.8.2
pytz 2022.2.1
requests 2.28.1
setuptools 56.0.0
six 1.16.0
thread6 0.2.0
urllib3 1.26.12
wheel 0.38.4
Im runnig a windows 10 machine, and im getting started on playing with virtual enviorments. I want to run a small fastapi application
I created a venv like this:
python -m venv venv
I then activated the venv, and installed my two dependencies:
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> pip install fastapi
and
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> pip install unicorn
Which seemed to work fine, running pip list also seems to indicate that i have what I need:
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> pip list
Package Version
----------------- ---------
beautifulsoup4 4.9.3
certifi 2020.6.20
cffi 1.14.3
chardet 3.0.4
crypto 1.4.1
cryptography 3.1.1
cycler 0.10.0
fastapi 0.63.0
idna 2.10
myModule 1.0.0
Naked 0.1.31
pip 21.0.1
pycparser 2.20
pycrypto 2.6.1
pydantic 1.8.1
PyYAML 5.3.1
requests 2.24.0
setuptools 49.2.1
shellescape 3.8.1
six 1.15.0
soupsieve 2.0.1
starlette 0.13.6
typing-extensions 3.7.4.3
unicorn 1.0.2
urllib3 1.25.10
wheel 0.35.1
But when I run my program it fails with the inmport of the fastapI:
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> python .\main.py
Traceback (most recent call last):
File "C:\Users\Ask\python_Projects\garse_dockerAPI\app\main.py", line 3, in <module>
from fastapi import FastAPI
Also, running python my terminal doesnt wanna do it either:
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import fastapi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'fastapi'
What's going on? why do i not have the dependencies i need?
EDIT:
In order to find the installation on my machine, I ran 'where python' in my normal terminal:
C:\Users\Ask>where python
C:\Users\Ask\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\Ask\AppData\Local\Microsoft\WindowsApps\python.exe
Which give sme two different paths. I dont really know what to do with this information?
running where pip:
C:\Users\Ask>where pip
C:\Users\Ask\AppData\Local\Programs\Python\Python39\Scripts\pip.exe
When I run it in my venv, the commands output nothing at all:
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> where pip
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app> where python
(venv) PS C:\Users\Ask\python_Projects\garse_dockerAPI\app>
I definitely recommend using python3 -m pip instead of pure pip. It might save you some headache. The reason: when I used pip to install new packages in a venv virtual environment, they ended up in my OS environment! But just using python3 -m pip did the trick.
To make sure that the packages are called from your virtual environment, you can use python3 -m PACKAGE_NAME instead of PACKAGE_NAME. For example, flower didn't work in my virtual environment, but python3 -m flower works with no problem.
You can directly ask python where it is executed from! Try this:
>>> import sys
>>> print(sys.executable)
/PATH/TO/VENV/bin/python
>>> print(sys.version)
'3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]'
Some extra info:
I am on Windows 10, using latest Python version, using latest pip version, using Pycharm as my IDE. I am making a keylogger program for a project and I cannot seem to get keyboard module working.
Also:
C:\Users\Hp>pip --version
pip 20.2.2 from c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8)
C:\Users\Hp>pip install keyboard
Requirement already satisfied: keyboard in c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages (0.13.5)
C:\Users\Hp>pip list
Package Version
altgraph 0.17
future 0.18.2
keyboard 0.13.5
pefile 2019.4.18
pip 20.2.2
PyInstaller 3.6
pywin32-ctypes 0.2.0
setuptools 41.2.0
The error message in PyCharm: C:\Users\Hp\Desktop\keylogger\venv\Scripts\python.exe C:/Users/Hp/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/keylog.py
Traceback (most recent call last):
File "C:/Users/Hp/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/keylog.py", line 2, in
import keyboard
ModuleNotFoundError: No module named 'keyboard'
Activate your virtual-environment
.\env\Scripts\activate
or
C:\Users\Hp\Desktop\keylogger\venv\Scripts\activate
Now install keyboard
pip install keyboard
#yedpodtrzitko already answered, I just want to make it clearer with solution-steps.
Python 3.5.1 |Anaconda 4.0.0 (x86_64)on OS X 10.11.3
>>> from sklearn import pipeline, model_selection
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'model_selection'
tried to:
upgrade six, sk-learn,
sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2
pip2 install six -U
pip install --ignore-installed six
pip install --ignore-installed ipython
even reinstall the anaconda...
Did NOT fixed.
Thanks for help
_________Updata________
I have checked that my six version is the newest one (version = "1.10.0")
import sklearn
sklearn.version
'0.17.1'
I found that there is no folder name "model_selection" in sklearn folder. But there is this folder in https://github.com/scikit-learn/scikit-learn/tree/3078d7d611329c46777d4004a1185a3626558efe/sklearn.
After install the dev version by
$ pip install git+git://github.com/scikit-learn/scikit-learn.git
Successfully installed scikit-learn-0.18.dev0
And then run a script which runs successfully in 0.17.1, it shows error:
from .pairwise_fast import _chi2_kernel_fast, _sparse_manhattan
ImportError: dlopen(/Users/Username/anaconda3/lib/python3.5/site-packages/sklearn/metrics/pairwise_fast.cpython-35m-darwin.so, 2): Library not loaded: libmkl_intel_lp64.dylib
Referenced from: /Users/Username/anaconda3/lib/python3.5/site-packages/sklearn/metrics/pairwise_fast.cpython-35m-darwin.so
Reason: image not found
What version of scikit-learn are you using? It looks like the latest, when I install for Python 3.5, is 0.17.1. Checking in the console:
import sklearn
sklearn.__version__
'0.17.1'
According to the documentation for this version that "model_selection" package doesn't exist. It does exist in the dev version. This should be why it is complaining.
I'm new to installing modules, etc, but believe I've done everything correctly and I'm getting errors. I'm following the instructions here:
https://developers.google.com/gdata/articles/python_client_lib#library
Steps:
1. downloaded Zip of gdata here:
https://github.com/google/gdata-python-client
2. unzipped and placed into my Scripts folder: C:\Python34\Scripts\gdata-python-client-master
3. went to cmd, above directory and installed: I did get a bunch of syntax errors (commas, etc), assuming this is why the next steps aren't working...
4. in python prompt, it says i have module:
[gdata 2.0.18 (c:\python34\lib\site-packages), google-api-python-client 1.4.2 (c:\python34\lib\site-packages), httplib2 0.9.2 (c:\python34\lib\site-packages), oauth2client 1.5.1 (c:\python34\lib\site-packages), pip 6.0.8 (c:\python34\lib\site-packages), pyasn1 0.1.9 (c:\python34\lib\site-packages), pyasn1-modules 0.0.8 (c:\python34\lib\site-packages), requests 2.7.0 (c:\python34\lib\site-packages), rsa 3.2.3 (c:\python34\lib\site-packages), setuptools 12.0.5 (c:\python34\lib\site-packages), simplejson 3.8.1 (c:\python34\lib\site-packages), six 1.10.0 (c:\python34\lib\site-packages), uritemplate 0.6 (c:\python34\lib\site-packages)]
5) But when I try to import gdata i get an error:
>>> import gdata.spreadsheet.service
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import gdata.spreadsheet.service
File "C:\Python34\lib\site-packages\gdata\__init__.py", line 26, in <module>
import atom
File "C:\Python34\lib\site-packages\atom\__init__.py", line 132, in <module>
CreateClassFromXMLString)
File "C:\Python34\lib\site-packages\atom\__init__.py", line 96, in mark_deprecated
optional_warn_function.func_name = f.func_name
AttributeError: 'function' object has no attribute 'func_name'
Any ideas?
Instead of trying to unzip to install, use pip:
http://pip.readthedocs.org/en/stable/installing/
You can install the library using pip install gdata:
https://pythonhosted.org/gdata/installation.html
Update: pip is a good way to install, but this was not actually the problem - the actual root problem was gdata compatibility with python2 vs. python3. The fix that worked is described here: https://github.com/google/gdata-python-client/issues/29
Specifically running this in the site-packages directory:
2to3 -w atom gdata
Be warned this will change many files, so having a backup or recovery strategy in place before beginning is strongly advised.