I have a virtualbox running centOS. I want to install WTForms and Flask_WTF. I have installed them using pip. However, there are import errors.
[vagrant#oclubs ~]$ pyshell
Traceback (most recent call last):
File "/srv/oclubs/repo/shell.py", line 12, in <module>
from oclubs import *
File "/srv/oclubs/repo/oclubs/__init__.py", line 12, in <module>
from oclubs import objs
File "/srv/oclubs/repo/oclubs/objs/__init__.py", line 15, in <module>
from oclubs.objs.classroom import Classroom
File "/srv/oclubs/repo/oclubs/objs/classroom.py", line 7, in <module>
from wtforms import BooleanField, SelectMultipleField
ImportError: No module named wtforms
Flask imports are fully functional. Any suggestions?
There are sometimes many python interpreters (which searches packages in different folders) and pips (which install packages to a different folders) installed. You can check where your interpreter searches packages by adding a code just before line which caused an error: import sys, os; print(sys.version); print(sys.executable); print(os.environ['PATH']); print(os.environ.get('PYTHONPATH')); print(os.getcwd()). Then run pip show wtforms and see where it was installed. If it's not in the PATH or PYTHONPATH, then pay attention to the pip, which you've used to install a package.
P.S. If you are using virtual env, ensure that you are installing a package with this env's pip, not your system's pip.
Please install again with user vagrant and try again. I assume you've installed in root user or anything.
[vagrant#oclubs ~]$ pip install WTForms
Related
I downloaded an open source library that I am making adjustments to, and I am trying to import my local version like from ... import my_library but getting ImportError: attempted relative import with no known parent package
When I try just import my_library I get the version that I installed via pip
% pip install -e /Users/sam/Documents/library
Obtaining file:///Users/sam/Documents/library
ERROR: File "setup.py" not found for legacy project file:///Users/sam/Documents/library
% pip install -e library
ERROR: library is not a valid editable requirement. It should either be a path to a local
project or a VCS URL (beginning with bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp,
bzr+lp, bzr+file, git+http, git+https, git+ssh, git+git, git+file, hg+file, hg+http,
hg+https, hg+ssh, hg+static-http, svn+ssh, svn+http, svn+https, svn+svn, svn+file).
i uninstalled the pip module and am trying
sys.path.insert(
0, "/Users/sam/Documents/dev/trading/ccxt/python/ccxt/__init__.py")
ccxt = importlib.import_module("ccxt") # Equivalent to "import package"
but am getting
Traceback (most recent call last):
File "/Users/sam/Documents/dev/trading/ccxt-scratch/main.py", line 4, in <module>
from Exchange import Exchange
File "/Users/sam/Documents/dev/trading/ccxt-scratch/Exchange.py", line 14, in <module>
ccxt = importlib.import_module("ccxt") # Equivalent to "import package"
File "/usr/local/Cellar/python#3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'ccxt'
The best way to install a library from source files that you are modifying is to use pip's editable mode.
pip install -e /path/to/the/library
This way the library will be loaded from the source files ad any changes to it will reflect in your virtual environment (if you are using one).
I am using the windows command prompt to install the scikit learn library using the command pip install -U scikit-learn. However, whenever I try to import it into my program I get an error stating that there is no module named 'sklearn'. Also, whenever I download the library using pip, for some reason, my pip package installer seems to break and pip is no longer recognized as a command on my cmd. I have numerous other modules which work perfectly fine so I don't see a reason as to why I can't get this specific library to work. I am still quite new to this kind of thing, so maybe I am missing something.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import sklearn
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn_init_.py", line 82, in
from .base import clone
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in
from .utils import IS_32BIT
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils_init.py", line 20, in
from scipy.sparse import issparse
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse_init_.py", line 227, in
from .base import *
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\base.py", line 4, in
from .sputils import (isdense, isscalarlike, isintlike,
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\sputils.py", line 8, in
from scipy._lib._util import prod
ModuleNotFoundError: No module named 'scipy._lib._util'
Try to upgrade pip to newest version by python -m pip install --upgrade pip considering you are still using Windows. And then try to download sciKitLearn by pip install sklearn
This is how I had solved my problem but keep note that it was about a year ago
If all this doesn't work, try VirtualEnv.
So, I'm trying to upload my python app to heroku but when I use a script with 'requests_toolbelt' it says is not found.
Here my log:
Traceback (most recent call last):
File "girl.py", line 12, in <module>
from Coffe import CoffeAPI
File "/app/CoffeAPI/__init__.py", line 29, in <module>
from requests_toolbelt import MultipartEncoder
ImportError: No module named 'requests_toolbelt'
Here my requeriments.txt:
requests-toolbelt==0.7.1
moviepy==0.2.2.11
requests==2.13.0
Do I need an specific buildpack to run 'requests_toolbelt'?
Try installing requests-toolbelt. Use below command to do that.
# pip install requests-toolbelt
Have you tried to install the package using your command line?
Navigate your command line to the path where you have python installed:
>path\easy_install.exe requests_toolbelt
or
>path\easy_install.exe requests-toolbelt
or
>path\python -m pip install requests_toolbelt
Hopefully this helps you
I had the same issue, and my solution was that
the package was installed by root user
and after changing the access properties of the files, it worked fine.
The command I specifically issued (on ubuntu-like system) was:
sudo chown $USER.$USER -R ~/.local/lib/python3.7/site-packages/
Whenever I am running any command using pip, I am getting the following error. I have tried uninstalling python,pip and reinstalling them back again. I also used
sudo apt-get autoremove
and then updated and upgraded
sudo apt-get update
sudo apt-get upgrade
And once again installed python and pip. I am still getting the same error whenever I run any command using pip.
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/home/shashank/.local/lib/python2.7/site-packages/pip/__init__.py", line 28, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/home/shashank/.local/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/home/shashank/.local/lib/python2.7/site-packages/pip/download.py", line 34, in <module>
from pip.utils.logging import indent_log
ImportError: No module named logging
Can anybody suggest a solution?
Edit
I have read the question which is used to flag my question as a duplicate.
I am not using a virtual environment and I have already tried the answer given over there. Moreover I am encountering a problem when I run pip in my terminal
The output of the command
locate logging
/etc/java-9-openjdk/logging.properties
/home/shashank/.local/share/Trash/files/logging.py
/home/shashank/.local/share/Trash/files/logging.pyc
/home/shashank/.local/share/Trash/info/logging.py.trashinfo
/home/shashank/.local/share/Trash/info/logging.pyc.trashinfo
/lib/lsb/init-functions.d/50-ubuntu-logging
/usr/lib/jvm/java-9-openjdk-amd64/jmods/java.logging.jmod
/usr/lib/jvm/java-9-openjdk-amd64/lib/logging.properties
/usr/lib/pm-utils/sleep.d/00logging
/usr/lib/python2.7/logging
/usr/lib/python2.7/dist-packages/pip/utils/logging.py
/usr/lib/python2.7/dist-packages/pip/utils/logging.pyc
/usr/lib/python2.7/logging/__init__.py
/usr/lib/python2.7/logging/__init__.pyc
/usr/lib/python2.7/logging/config.py
/usr/lib/python2.7/logging/config.pyc
/usr/lib/python2.7/logging/handlers.py
/usr/lib/python2.7/logging/handlers.pyc
/usr/lib/python3/dist-packages/UnityTweakTool/config/logging.py
/usr/lib/python3/dist packages/UnityTweakTool/config/__pycache__/logging.cpython-35.pyc
/usr/lib/python3/dist-packages/plainbox/impl/logging.py
/usr/lib/python3/dist-packages/plainbox/impl/__pycache__/logging.cpython-35.pyc
/usr/lib/python3.5/logging
/usr/lib/python3.5/logging/__init__.py
/usr/lib/python3.5/logging/__pycache__
/usr/lib/python3.5/logging/config.py
/usr/lib/python3.5/logging/handlers.py
/usr/lib/python3.5/logging/__pycache__/__init__.cpython-35.pyc
/usr/lib/python3.5/logging/__pycache__/config.cpython-35.pyc
/usr/lib/python3.5/logging/__pycache__/handlers.cpython-35.pyc
/usr/share/icons/hicolor/16x16/categories/applications-microblogging-panel.png
/usr/share/icons/ubuntu-mono-dark/categories/22/applications-microblogging-panel.svg
/usr/share/icons/ubuntu-mono-dark/categories/24/applications-microblogging-panel.svg
/usr/share/icons/ubuntu-mono-light/categories/22/applications-microblogging-panel.svg
/usr/share/icons/ubuntu-mono-light/categories/24/applications-microblogging-panel.svg
/usr/src/linux-headers-4.4.0-59-generic/include/config/fusion/logging.h
/usr/src/linux-headers-4.4.0-59-generic/include/config/scsi/logging.h
/usr/src/linux-headers-4.4.0-59-generic/include/config/sfc/mcdi/logging.h
/usr/src/linux-headers-4.4.0-62-generic/include/config/fusion/logging.h
/usr/src/linux-headers-4.4.0-62-generic/include/config/scsi/logging.h
/usr/src/linux-headers-4.4.0-62-generic/include/config/sfc/mcdi/logging.h
It's obvious from your traceback that you have a version of pip installed in your home directory, at /home/shashank/.local/lib/python2.7/site-packages/pip/. Delete that. If you aren't certain what else is contained there, better delete all /home/shashank/.local/lib/python2.7. After you delete it, it will use the system's default pip that you installed with apt.
I have to use python-elasticsearch library on a machine where I could only execute programs. I am trying to use elasticsearch module by appending sys.path as mentioned below. I am facing below issue. It looks like the problem related to what is mentioned here
https://github.com/elastic/elasticsearch-py/issues/253 . But how do I resolve this when I dont have sudo access or any sort of upgrade access.
**Note :**I don't have sudo access on this machine so I cannot have venv, pip etc.
import sys
sys.path.append('/tmp/elasticpy/elasticsearch-2.3.0')
from elasticsearch import Elasticsearch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/__init__.py", line 17, in <module>
from .client import Elasticsearch
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/client/__init__.py", line 5, in <module>
from ..transport import Transport
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/transport.py", line 4, in <module>
from .connection import Urllib3HttpConnection
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/connection/__init__.py", line 3, in <module>
from .http_urllib3 import Urllib3HttpConnection
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/connection/http_urllib3.py", line 2, in <module>
import urllib3
ImportError: No module named urllib3
#nehal Thanks for your suggestion I was able to get it fixed. Please find the
series of steps I used to install
Used easy_install to install package pip
Appended PYTHONPATH
used pip to install virtualenv
Activated new virtualenv
Installed elasticsearch using pip
export PYTHONPATH="${PYTHONPATH}:/tmp/pytest/"
easy_install --install-dir /tmp/pytest/ pip
pip install virtualenv --prefix /tmp/pytest/
export PATH="${PATH}:/tmp/pytest:/tmp/pytest/bin"
export PYTHONPATH="${PYTHONPATH}:/tmp/pytest/lib/python2.7/site-packages"
cd /tmp/
virtualenv venv
source venv/bin/activate
pip install elasticsearch