I am new to python and I switched from Jyputer Notebook working environment to python console (python 3.8.1 shell). I am facing issue in installing packages which I was able to install/import through notebook.
pip install dask
pip install pyodbc
pip install pysftp
pip install selenium
e.g:
>>> pip install pysftp
SyntaxError: invalid syntax
>>>
>>> pip install selenium
SyntaxError: invalid syntax
>>>
While import is working for some libraries.
>>> import csv
is ok
>>> import pysftp
Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
import pysftp
ModuleNotFoundError: No module named 'pysftp'
>>>
Pip is a utility run from your regular terminal, not a python library so it works outside of a python shell
To install a python package, open your cmd (windows) or gnome terminal(linux):
pip install <package-name>
To install a package in your python source code, there is a deprecated method:
import os
os.system("pip install <package-name>")
Installing a pip package within a Jupyter Notebook:
! pip install --user <package>
Related
I have successfully installed the bitarray package, because I can find it after the command: pip list.
But when I try to import it I get :
>>> from bitarray import bitarray
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from bitarray import bitarray
ModuleNotFoundError: No module named 'bitarray'
What can I try to solve it ?
I'm using Ubuntu 18.04.5 .
You can install package as python3 -m pip install bitarray. May be when you did pip install bitarray, it install your package for python2.
Ubuntu comes with two python versions. If you just ran pip install x it installed it into python 2.7. You're probably using python3, so you wanna install with pip3 install x
Just to make sure you are running correct pip, try running "pip -V" or "pip --version", it gives you which version of python it refers to. In terminal it looks something like this pip version check
Its also possible that you might have pip for say python 2.7, pip3 for python 3.6, and pip3.7 for python 3.7, if you have multiple versions of python installed.
For simplicity you can set the most frequently used pip version as pip by setting an alias in ~/.bashrc. This is done by adding the following line in bashrc:
alias pip=pip3.6.
After this you can try and install the packages and import it swiftly.
I tried to install pip manager using the file get-pip.py as mentioned in the documentation- https://pip.pypa.io/en/stable/installing/
So, I downloaded the file and ran python get-pip.py and as a result, I had permission issues. So I again ran sudo python get-pip.py and it worked.
Now I wanted to install numpy. So I ran pip install numpy and it showed me the Import Error saying-
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named pip
But again when I ran sudo pip install numpy, it worked and got installed. Now, for every python script involving these pip packages, I have to run the script using sudo which I don't like. So how can I resolve these permission issues?
Just to mention-
python v2.7.12
pip v9.0.1
pip installation location- /usr/local/lib/python2.7/dist-packages
I am trying to install something using "python setup.py install" but it shows me this error :-
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup
ImportError: No module named setuptools
I have installed this missing module using "pip install setuptools". But still it shows me the same error .I have also tried to install this using "sudo apt-get install python-setuptools" but the problem still remains the same. Help me in this issue
If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version:
On Linux or macOS:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
If you’re using a Python install on Linux that’s managed by the system package manager (e.g “yum”, “apt-get” etc…), and you want to use the system package manager to install or upgrade pip, then see link
I'm trying to generate .docx files using Python. I searched the web and posts here and found a module:
https://github.com/mikemaccana/python-docx/blob/master/README.markdown
It says to install using easy_install or pip, which I have no idea how to do. I went to python website to install pip from the instructions given on python documentation:
http://guide.python-distribute.org/installation.html
So I downloaded and followed directions:
$ tar xzf pip-0.7.2.tar.gz
$ cd pip-0.7.2
$ python setup.py install
But when I do python setup.py install, I get error message:
Johns-MacBook-Pro:pip-0.7.2 John$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from setuptools import setup
ImportError: No module named setuptools
Can someone please help me install step by step for a newb? Thanks in advance for all of your help!
Pip can install straight from the git repository
You just have to tell him to use git and give him the URL of the git rep
pip install git+git://github.com/mikemaccana/python-docx.git
You will also need to install lxml (as written in the setup.py) and PIL (as you will discover when you try to import the module).
pip install PIL
pip install lxml
pip install python-dateutil
I tried to import the module but i am getting the error shown below:-
sh-3.2# python -V
Python 2.6.4
sh-3.2# python -c "import httplib2"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named httplib2
How to fix this Error?
httplib2 is not part of the Python standard library. It's an external package you must install yourself.
using pip:
pip install httplib2
You need to install the httplib2 package from your package manager.
On Ubuntu:
sudo apt-get install python-httplib2
I suppose you could start by installing httplib2.
Download it?
Make sure it's on your PYTHONPATH
Suppose you can start by installing it like :
$ pip install httplib2
you can try the same thing with easy install too, or if you wanted to install in locally and not over the network then go to httplib2 github .
Clone/download it to your computer. Now go to the downloaded httplib2 folder location and run the setup.py like this :
$ setup.py install
If on windows, make sure you have successfully installed python first and have set the environment variables path successfully.
This is a common command to install any module using pip or by locally downloading and looking for the foldert location>setup.py file and trying the second command mentioned above.
FOR WINDOWS:
if python is installed & set as environment variable
python -m pip install httplib2