How to install a package to python which is not default [duplicate] - python

This question already has answers here:
no module named zlib
(9 answers)
Closed 6 years ago.
I am trying to add zlib package to my python. However, after I install it using "yum install zlib", only the default python (which is python 2.4.3) can import it. While the other python (3.4.4) still cannot use zlib.
When I try to import zlib in python 3.4.4 by
import zlib
It displays
Traceback (most recent call last):
File "< stdin >", line 1, in
ImportError: No module named 'zlib'
My question is, how can I install package to python which is not default?
PS. I installed both zlib and zlib-devel
Thanks

You might need to install the zlib-devel package as well: yum install zlib-devel.
Otherwise you need to post the full error message when you try to run import zlib.

Related

ModuleNotFoundError: No module named 'requests' after pip install [duplicate]

This question already has answers here:
ModuleNotFoundError: No module named 'requests' but it's installed?
(2 answers)
Closed 1 year ago.
I know similar questions have been asked before but I couldn't find the solution to my problem.
I am getting the following error message after trying to import requests:
C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe C:/Users/Jm/PycharmProjects/Test/Test_001
Traceback (most recent call last):
File "C:/Users/Jm/PycharmProjects/Test/Test_001", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
I only have one version of python installed and python -m pip install requests is saying all the requirements are already satisfied.
Run this code:
C:\Users\Jm\PycharmProjects\Test\venv\Scripts\python.exe -m pip install requests
This forces the installation directory to your python install.
This gives a much different effect than simply python -m pip install requests
As #Daniel Scott mentioned before use the command mentioned above or below
$: path-to-your-python-command -m pip install name-of-module
If you are using linux/mac then you can find path-to-your-python command using:
$: which python3
/usr/bin/python3
Lets say your python is installed here /usr/bin/python3 and the module you are installing is requests. Then you can use:
$: /usr/bin/python3 -m pip install requests

Python3 ImportError: No module named '_tkinter' [duplicate]

This question already has answers here:
python ImportError: No module named Tkinter
(5 answers)
Closed 4 years ago.
On my Linux Mint 18, I've tried to install Python 3.6.1 beside my 3.5.2.
With these commands:
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xJf Python-3.6.1.tar.xz
cd Python-3.6.1
./configure
make
make install
The installation was successfully but, now, every time I try to import tkinter, I have the same error:
>>> from tkinter import tk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
I've no idea how to get rid of this issue, and how remove the 3.6.1
I think you still need to install the tkinker package. You can do this by simply typing:
sudo apt-get install python3-tk
The issue as I see is that you are still calling your python3.5 binaries which might be set as default python interface. See the line in your error which tells the version of python it is referring to:
/usr/local/lib/python3.5/tkinter/
If it's a UNIX / Linux flavour you are using, you can check where are your python binaries by using
whereis python
and you will get a list of all the flavours and places it is in:
You simply call out your chosen flavor to work with, which I am guessing might be
/usr/local/bin/python3.6
and then list the available modules to check if Tkinter is available or not, although it is highly unlikely not to as it comes bundled as a standard library.
If you are using pycharm then you can simply write:
from tkinter import *

python3 cannot load qrcode module [duplicate]

This question already has answers here:
How to use pip with Python 3.x alongside Python 2.x
(11 answers)
Closed 6 years ago.
I have installed qrcode package as pip install pyqrcode
Then when I open a python2.x shell and import it there, no errors are given. But when I open a python3 shell and try to import it there it says
ImportError: No module named 'qrcode'
I import it as import qrcode
When I installed the package with pip it says Downloading PyQRCode-1.2.tar.gz, meaning that it is installing the last version. But in pypi
it says that it also support python3.
What's the correct way to import it?
You need to download a separate package for python 3. pip3 install pyqrcode
Then you can access it. Of course you will need to install pip3 first if you don't have it.

Install python pymysql on win7 [duplicate]

This question already has answers here:
Python 3: ImportError "No Module named Setuptools"
(22 answers)
Closed 8 years ago.
So I am completely unfamiliar with python and wanted to install pymysql.
This is the actual command I typed in cmd and the response I got:
C:\>d:\python27\python d:\pymysql\setup.py install
Traceback (most recent call last):
File "d:\pymysql\setup.py", line 2, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
I have python 2.7.8 and MySQL 6.x
I followed the instructions from here.
I haven't tried to search for the error message but have not found anything. Maybe some of you guys can help?
Install setuptools from here first, and then try to install pymysql again.

Python: ImportError: No module named pkg_resources [duplicate]

This question already has answers here:
No module named pkg_resources
(38 answers)
Closed 8 years ago.
In order to run Pelican, I installed python2.7 and modified first line of file /usr/bin/pelican-quickstart
from:
#!/usr/bin/python
to
#!/usr/bin/env python
when I type pelican-quickstart an error occured:
Traceback (most recent call last):
File "/usr/bin/pelican-quickstart", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
I found "pkg_resources" is in this directory:
/usr/lib/python2.6/site-package/
I'm wondering if I have to install some packages after python2.7 is installed?
or, how can I solve this problem.
The problem must be an issue with your setup tools, try the following:
pip install --upgrade setuptools
pip install --upgrade distribute
If this solution doesn't work, you can check the following answer
You said
/usr/lib/python2.6/site-package/
but should be
/usr/lib/python2.6/site-packages/

Categories