Installing modules like pygal so they work in Spyder - python

I'm a Python beginner working with Spyder, who must pip install modules for my class; pygal, for example. When I try to install, or reinstall as an administrator, this is what I get:
C:\WINDOWS\system32>pip install pygal
Requirement already satisfied: pygal in c:\users\flora\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (2.4.0)
Yet when I try to import the module in a Spyder file, this is the message I get:
Traceback (most recent call last):
File "C:\Users\flora\crash python\data mining\world_population2.py", line 2, in
import pygal
ModuleNotFoundError: No module named 'pygal'
And there's no sign of it in the dependencies in Spyder. Same thing using IDLE 3.8. I had assumed that Spyder or Anaconda would automatically be able to use it. Does it have something to do with WHERE I have saved it? I have tried reinstalling Anaconda, restarting my computer, etc. No difference.
Thanks in advance for any ideas.

No idea if this will help but if you goal is to use pygal you can try using a different ide with python build in. It does not run the most current version of python by default but you can change it to the version of python you have installed.
Try using Thonny I was able to import and run some code from pygal.

Related

ModuleNotFound error but module has just been installed

I'm using Windows 10, Python 3.6.4. I'm trying to use the module Pyperclip and have installed it with pip:
c:\Users\Bertie>pip install pyperclip
Requirement already satisfired: pyperclip in c:\python36\lib\site-packages (1.8.0)
But when I try to run a program which uses this module, I get this error:
c:\Users\Bertie\scraping.py test
Traceback (most recent call last):
File "C:\Users\Bertie\scraping.py", line 3, in <module>
import webbrowser, sys, pyperclip
ModuleNotFoundError: No module named 'pyperclip'
How can I fix this? Thank you.
The reinstall trace shows you install the packge successflly for python36.
Check if there is more than one python in your system. Type "python" in your windows cmd console, and check the python version to see if python36 is the default one. Then explicitly use the python interpreter to start the script "python your_python_script.py".
Where is the py file? Maybe try cd-ing into the folder and run python (python3) scraping.py?
Also check that you have installed the correct interpreter and are using the correct version of python.
Maybe You Installed pyperclip in conda env or a virtualenv and you forgot to activate it ?
Because This Has Happened To Me Many Times.
Or Maybe You Have 2 Instances Of Python installed on your computer and you accidentally installed pyperclip in the other instance of python ?

ModuleNotFoundError: No module named 'pynput' Python3 and pip3

I want to use 'pynput', so I used pip to add it to my environment.
The installation proceeds without problem.
But I am unable to import it into my project.
I am using python 3.8.1 on my environment.
I used pip3 for installation.
I have already tried to install pynput, uninstall it and reinstall it multiple times.
My .py file doesn't have a confusing name like "pynput.py"
I am comfortable with my environment when I try to execute my file.
I am trying to run from my terminal or VSCodium, and neither of them works.
And I work on Debian 10.
pip freeze :
pynput==1.6.7
python-xlib==0.26
six==1.14.0
Traceback :
Traceback (most recent call last):
File "./play.py", line 6, in <module>
from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'
So I don't understand why it doesn't work.
thank you in advance for your help :)
When creating my project, I was not working under an environment, so I used the classic shebang: #!/bin/python3.
Then, I went under an environment to use pynput, but I just forgot to change my shebang to #!/usr/bin/env python.
So, actually, I didn't risk finding pynput
It might be possible you have two versions. Rry installing with python3 -m pip install pynput or you should use some older version of Python. I am using 3.7.5 and its works perfect for me.
Try importing from the terminal.

pyodbc module not found

I am facing a situation where modules like pyodbc which used to work earlier (3 weeks back) are not working anymore in my laptop. I am repeatedly getting Module not found error.
To resolve it by myself, I have gone through similar articles in stack overflow and implemented some suggestions like this. Yet the issue still persists. My machine (Windows 10) has only one python version (python v3.7.2), and I have never created any virtualenv.
C:\Users\Kris\eclipse-workspace\SQLPyODBC>conntest.py --serverName "IDEA-PC\SQLEXPRESS" --name "SampleStore" --trustedConn "yes"
Traceback (most recent call last):
File "C:\Users\Kris\eclipse-workspace\SQLPyODBC\conntest.py", line 1, in <module>
import pyodbc
ModuleNotFoundError: No module named 'pyodbc'
The referenced package is available under C:\Users\Kris\AppData\Local\Programs\Python\Python37-32\Lib\site-packages directory. Also the path of python interpreter in eclipse IDE (PyDev) is pointing to correct python executable path.
Just to test, I have downloaded pymssql module, and guess what... it is also showing the same error message. I have uninstalled and re-installed packages. No solution.
If you're using Anaconda install using following code,
conda install -c anaconda pyodbc
Before importing pyodbc in python, you should install the module by using pip directly from cmd.
pip install pyodbc
if that does not work, try using pip to uninstall and install it again after a restart (Or kill all python related tasks). Hope it works

Installing and importing Python Modules onto OS X

I've been trying for a couple of hours already. It seems IDLE can't find any third-party module. I am a Python beginner.
Here is some info about my system:
OSX version: 10.11.5
python version: Python 2.7, Python 3.4, Python 3.5
The initial installation using pip (among other methods) seems to work fine. When I repeat the installation, terminal responds with:
Requirement already satisfied (use --upgrade to upgrade): pyperclip in
./anaconda/lib/python3.4/site-packages
However, when I go to IDLE (Python 3.4) and try to import the module, IDLE responds with:
Traceback (most recent call last): File "", line 1, in
import pyperclip ImportError: No module named 'pyperclip'
I have read that it may have something to do with my PATH or some virtual environment. I’ll be frank, I’m not sure what to make of these as they seem beyond my current ability.
This inability to import modules is becoming an almost insurmountable roadblock to advancing with Python. If you can offer any ideas on what I can do or can ELI5 the solution, I am forever in your debt?
It seems you are using conda, but you are trying to install the pyperclip module with pip. Have you tried running conda install pyperclip?
As stated here:
Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side but they do not interoperate either.

no module named 'numpy' (windows 7, python 3.4.3, numpy-1.9.2)

Please only respond to this post if you use Python on Windows, rather than Mac or Linux.
Error message:
>>> import numpy
Traceback (most recent call last):
File "stdin", line 1, in <module>
ImportError: No module named 'numpy'
Questions:
Regarding windows 7, python 3.4.3 and numpy-1.9.2, are there any
conflicts that would prevent these from working together?
Into which directory (please write out the complete directory path
starting with "C:") should I extract the contents of the numpy zip
file?
What is the exact command that I need to type into python command
prompt in order to install numpy?
Thanks in advance for your assistance
I was also facing this issue where in I tried using
import numpy
But it has given me error "ImportError: No module named 'numpy'"
I installed numpy using "C:\user>python -mpip install numpy" and it was successfully installed.
However I was again getting the same error
Then I checked that the path where in numpy was intalled was not listed in
import sys
print(sys.path)
Then I appended my path wherein numpy was installed using ">>> sys.path.append(r"C:\Users\xxxx\AppData\Roaming\Python\Python38\site-packages").
The above command worked fine, still problem not resolved then I restarted my python session again.
Finally it worked..!!!!(As after every append we have to restart our python session).
1) No there isn't.
2) You can use pip. pip install numpy
If you don't have pip installed, install it, its the most often used way of installing python packages. Yes it is possible to do under windows.
3) Once you have the python command prompt, you already have python installed.
1) no
2) It doesn't actually matter as pip or the installer will figure that out for you. However, just so you know, pip or whatever will install numpy into your site-packages folder.
3) I recommend downloading the NumPy installer from SourceForge:
http://sourceforge.net/projects/numpy/files/NumPy/1.9.2/
Then you don't have to worry about having the right compiler installed. However, if you want to use pip, then you'll need to install the appropriate compiler. This is documented at the following locations:
Microsoft Visual C++ Compiler for Python 3.4
https://matthew-brett.github.io/pydagogue/python_msvc.html
I'm not even close to an expert on Python. That said, I like the notion of "keep it simple." I chose to install a Python distribution that already includes numpy. Specifially I installed Python(x,y). Everything seems to be working just fine right after install. I appreciate all those who commented on my question. Thanks

Categories