ModuleNotFound Error in Python 3.6 when using fake_useragent - python-3.x

Trying to import python module fake_useragent
Command prompt stating that it has already been installed.
Anybody knows how come I still cannot import the fake_useragent module in python even though I have already installed it?

Thank you very much, I have solved the problem. I have tried to uninstall and reinstall the module but it still did not work. I tried to use Jupyter Notebook as well as Pycharm to import the module but I could not. Eventually, I tried to import the module using IDLE, which is the default IDE which comes with downloading and installing Python from python.org and I was successful. Therefore, I suspected that I had accidentally installed two versions of Python on my computer. The problem is that I have already installed Python 3 inside my computer. However, on top of that, I have also installed the Anaconda package, which also installs its own version of Python 3. However, when I use pip to install the fake-useragent module, I am installing it for the original python version. Therefore, when I use Jupyter notebook which is part of the Anaconda package, I could not input the module. I could not import it for Pycharm as well since I used the Anaconda interpreter as Pycharm's default interpreter. After I have uninstalled Anaconda and changed the default interpreter for Pycharm under settings back to the original version of Python which I have installed, I'm able to import the fake-useragent in python.

Related

'xlrd' installed, but getting the error: "Missing optional dependency 'xlrd'..."

I'm using Python 3.7 and I recently upgraded to Spyder 4.2.0 from Spyder 4.1.5. Now when I run my code (which was working fine before) I get the following error:
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
So apparently Spyder thinks 'xlrd' ('Excel Reader'?) is not installed. So I went to the Anaconda prompt and tried pip install xlrd, but it replied with
Requirement already satisfied: xlrd in c:\users\michael\anaconda3\lib\site-packages (2.0.1)
I tried uninstalling and reinstalling xlrd anyways, using pip, but it didn't change anything. How do I resolve this error?
Also, I'm not sure if this matters or not, but I originally installed Spyder via Anaconda, whereas now I just downloaded Spyder 4.2.0 by itself, through this link: https://github.com/spyder-ide/spyder/releases.
Also, on the linked github page, it says: "If you are new to Python or the Scientific Python ecosystem, we strongly recommend you to install and use Anaconda. It comes with Spyder and all its dependencies, along with the most important Python scientific libraries (i.e. Numpy, Pandas, Matplotlib, IPython, etc) in a single, easy to use environment."
I had at first assumed this was meant for people downloading Python/Anaconda for the very first time, but now I'm thinking this applies to a semi newbie at Python such as me? As someone who is not very familiar with how packages and dependencies work, should I be downloading Anaconda every time I want to update Python or Spyder?
Apologies for the (probably) silly newbie question...
This sounds like you needed to re-start Spyder for it to pick up the package you installed.
However, as the author of xlrd, I would suggest you do the following:
Stop Spyder
conda install openpyxl
Start Spyder.
Change your pandas code to be pd.read_excel(..., engine='openpxyl')

Cannot import ffn after installing anaconda

I recently installed Anaconda spyder 2020 version, resulting in Python 3.7.6 being installed.
I previously had ffn installed and working.
Now when I run code that tries to import ffn, it comes up with Module not found - No module named 'ffn'.
However, when I issue pip freeze at the console, I can see ffn == 0.3.3
Can anybody shed any light on why I have having problems importing ffn?
If you install anaconda it will automatically install its own version of python with a specific directory for site-packages so either you need to find and use your old python binary or install ffn again this time with the newly installed anaconda since just syncing the two site-packages directories won't work because minor releases of python (e.g 3.7 and 3.5 ) aren't necessarily compatible.

Trouble installing and importing python packages

I've recently downloaded the python package colorama to use in a small project, I'm having trouble installing/importing it.
For a bit more background, I use MacOS and I have two versions of Python on my Mac; 2.7 which comes with the mac by default and 3.7 which I use to code. The package seems to have been successfully installed, as when I try to reinstall it I get the message below. However, when I try to import the colorama module using a script in python 3.7 it simply tells me it doesn't exist.
Have I installed it for the wrong version of Python? And, if so, is it possible to make 3.7 my default version of python to prevent this from happening again? Or am I wrong about this issue entirely?
Requirement already satisfied: colorama in ./Library/Python/2.7/lib/python/site-packages (0.4.1)

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

How to link anaconda to python 3.6

I have already installed the anaconda module and it already has built-in pandas package that I want to make use of. I have python 3.6 installed in my machine. Environment variables for anaconda and python are set as well but I am still unable to import pandas on my python console.
Could anyone help me import the pandas? I can not make use of pip tool as I am working on my company's machine. Due to security issues, I am not allowed to download any package through pip. I want to make use of pre-installed anaconda module. Help me link my python to Anaconda.

Resources