pyperclip module in python 3.4 not in python 3.5 - python-3.5

I am completely new to programming and Linux OS.
In my Linux machine, I edited my bashrc so that when I type python, it calls python3. I have python 3.4 and python 3.5.2 installed. Recently, I install this module pyperclip using pip3 install.
My problem is when at python 3.5.2, the pyperclip module couldn't be found, I couldn't import it at terminal. When at python 3.4, I get to import the module.
Being completely new to Linux, I have no idea how to access the "pyperclip" module via python 3.5.2
I bought this book "Automate the Boring Stuff with Python." and the projects are really interesting.
Is it advisable to have more than one version of Python in my machine? Can I just use only one? How to I import pyperclip module in python 3.5.2?

Try this in Terminal.
pip3 install
pip3 install setuptools
pip3 install pyperclip
However you may need to have downloaded the zip pyperclip module first. Mine was in my Downloads directory on my Mac before I ran the previous three pip lines in Terminal.

Related

no module named `numpy` in python 3.6 interpreter

I'm using Python 3.6 v in Ubuntu 18.04LTS. I installed numpy package using pip. When i used Python 3.6 interpreter it throws
ModuleNotFoundError: No module named 'numpy' and for Python2.7
interpreter it didn't throws any error. Any suggestions will be very helpful. I searched in google and github nothing helped me.
Based on the outputs you posted -
your pip and python are pointing to version 2.7
if you try pip install numpy you will install into your python 2.7 env
if you start python interpreter by default you'll be starting python2.7 and you should be able to find numpy package installed.
if you want to do the same in python3.xx use python3 , pip3 or use
virtual environments

import ortools in mac

I am trying to run some code using ortools on a python environment. I did not have troubles on a windows machine but I am having problems on mac (10.12.6). if in my virtual environment I run
pip freeze
or
conda list
ortools appears in my list of installed packages. But if I try to use it
ipython
from ortools.linear_solver import pywrapplp
I get an error saying that there's no module named ortools. If I go to
mac/anaconda3/envs/nameenv/lib/python3.6/site-packages I do have a folder called ortools with some python files including pywrapplp. Do you know what I am doing wrong ?
EDIT
following request from coments:
import os
os.getcwd()
returns '/Users/imac'
which ipython
/anaconda3/bin/ipython
Installing ortools is a bit of a headache. It was some days ago, I think I finally made it with
easy_install ortools
I think it is a problem with the path. I guess because I did not install it with conda it does not find the package. I got around writting:
sys.path.append('/anaconda3/envs/env_name/lib/python3.6/site-packages/')
at the begining of my ipynb. That way I can run ortools.
You could have several python interpreter installed (python2 and python3)
So if you want to use it with ipython, which seems to be bind on python3 in your case.
First check if you have pypi package ortools installed
ipython -m pip show ortools
If you got an error it means the package is not installed.
so you can easily install it using:
ipython -m pip install --user ortools
note: We provide Pypi ortools package (64 bits) for Manylinux, Windows and MacOS.
You can also rebuild it from source https://developers.google.com/optimization/introduction/installing/source

Install working rosbag package for Jupyter Notebook (Python 3)

Trying to plot the data from ros topics in a rosbag file. My system by default had Python 2.7 and I installed Python 3.5 just to work with Jupyter notebooks.
Now I have installed several packages twice, once for Python 2 and again for Python 3. Although most packages are compatible with both versions of Python, I am beginning to wonder if all the ros packages are compatible here.
For the image in this question, initially I was getting an error 'No module named 'rosbag_pandas'', then I installed it with pip3. Now I am facing the error shown in the image with regards to rosbag. I have searched high and low for a quick fix but to no avail. I read online that some packages only work with either Python 2.7 or with Python 3.5. Is that what's happening here?
FYI I have installed pyrosbag with pip and pip3 both. Still facing this issue. Could really use some help with this.
I faced the same problem and found a workaround for me. Basically, on top of the usual python 3 installation, install a python 2 kernel for jupyter notebook, as described here, as follows:
python2 -m pip install pip
python2 -m pip install --upgrade ipykernel
python2 -m ipykernel install
Not sure if there is indeed a python 3 package for rosbag but using the python 2 kernel you can import rosbag files to save them in another format for further processing in python 3.

Python 3 can't import PyGObject

I'm trying to use PyGObject with Python 3, (either on Debian or Linux Mint) so I can use Gtk3+ and Glade for creating GUIs.
The problem is this:
In Python 3:
import gi
says module 'gi' not found.
I installed python3-gi from the repository, and Python 3 still says module not found when I try to import it.
However, Python 2 detects the module.
In Python 2, if I do
import gi
It works, but not with Python 3. I'm only interested in Python 3.
Any suggestions?
I ended up going with a different Linux distro which had PyGObject already installed for Python 3 - Ubuntu-MATE. Before, I was using Linux Mint.
the solution which worked out for me
pip install pycairo
pip install pyGObject

Python3 can't find urllib3

I have Python 2.7.3 installed alongside Python 3.2.3 on an Ubuntu system.
I've installed urllib3 using pip and can import it from the python shell. When I open the python3 shell, I get a can't find module error when trying to import urllib3. help('modules') from within the shell also doesn't list urllib3.
Any ideas on how to get python3 to recognize urllib3?
You need to install it for each version of Python you have - if pip installs it for Python 2.7, it won't be accessible from 3.2.
There doesn't seem to be a pip-3.2 script, but you can try easy_install3 urllib3.

Resources