I 'm new to python, and I need some help.
At first i install pyperclip using command window: "pip3 install pyperclip". The command window responsed that I have downloaded the module successfully.
However I can not use pyperclip in my code. When I coded "import pyperclip", there was an error: "No module name pyperclip..."
I then changed the directory of the command window direct to the address of Python, but nothing seem to work.
I use PyCharm for my coding.
Hope you can hep me solve this problem.
Python responsed "No module name pyperclip..."
It clearly that I have download the module.
Find path to python which you are using and then do something like:
path/to/python -m pip install pyperclip
Or better use conda or pipenv
The problem is that you have installed the package for another interpreter, one that is not used by your current project.
How to install modules for a particular interpreter in PyCharm: https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
You can also select the interpreter for the particular configuration (setup used for running a script):
https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html
Related
My error
It does this for every module that I try to import?
I put everything that is needed in path.
You can install using command prompt. Open command prompt and type pip install numpy
apparently you are using anaconda make sure you are in the correct profile, if you are already I suggest you try using pycharm to create a virtual even, or even try to install any module locally
I wrote my first program with a non built-in module and it works when I run it in pycharm, but when I try to run it in cmd I get an error: app.py, line 1, in <module> from pytube import YouTube ModuleNotFoundError: No module named 'pytube'
I've tried installing pytube module via cmd once again, but the problem still occurs
EDIT: The rest of my scripts are working fine (there are using built-in only modules)
Have you tried installing Pytube with pip on your command prompt? Enter: pip3 install pytube in your terminal and rerun the script. It wasn't clear with the original post if you already did this.
If this doesn't work, try running your script with the -m flag: $ python -m main
A more detailed answer for this issue is already available here.
Did you create an environment when you were in pyCharm? There's a chance you have to activate the env when you are in the cmd prompt.
Console without an environment
C:\path>
Activate environment named 'base'
C:\path>activate base
Console with an environment named 'base'
(base) C:\path>
Ok, so after some research and trying different solutions, I managed to run my script just by copying the missing module to the same directory as my app.py file, I don't know if it's the best solution, but it works.
I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?
I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.
You should open the terminal inside the VSCode and install the modules you want.
something like👇
if that's not you meant, please let me know.
First of all I would advise you to select the current Python version you have. It has been explained here:
VSCode: There is no Pip installer available in the selected environment
Next, you should check is the pip installed in your Python main directory or not, by checking how to do on this website:
https://pip.pypa.io/en/stable/installing/
or this thread
How to use pip with Visual Studio Code
by typing
py -m pip
in your terminal, like
C:\Users\m\Desktop\Python> py -m pip
You should have the list of commands and general options which can be used. One of them is install
On the Python library platform, you always have the command to be copied in order to the installation of package you want.
In your terminal, the initial command should look as:
PS C:\Users\m\Desktop\Python> py -m
to which you should append the command prepared on the Python library platform (by copying it and pasting).
C:\Users\m\Desktop\Python> py -m pip install openpyxl
That's it. The package should be installed in your Python folder, what you will see in the terminal.
If everything is alright, you just need to type
import openpyxl #or other package name, which you downloaded
and use it!
Unfortunately! for now, only possible way is terminal.
I wanted to pack my script using pyInstaller. I run pyinstaller file.py -F, file is created successfully, but when running I get ImportError: No module named 'praw'. So I created new file containing only import praw and run pyinstaller file.py -F --hidden-import=praw but still get the same error when running.
I was unable to find anything similar, most issues were solved by using --hidden-import.
Any ideas on how it can be solved?
EDIT:
praw is installed inside virtual environment and running the script directly works as expected.
Seem pyinstaller run outside the virtualenv.
Try switch to your virtualenv and run:
python -m PyInstaller -F file.py
I'll recommend to look at pyenv or virtualenv. Activate these env's and install the praw module here. This should work.
This command might help you out. It installs the Praw module for you. Make sure you have pip installed!
pip install praw
I found a way to solve the issue:
When using Python2.7, or starting the shell like python2, we need to do
python2 -m pip install --user praw
to make sure they are linked during installation.
Same idea for python3 shell.
I have installed the modules (for example: configobj, matplotlib, etc.) but when I try to import these modules in my Python script and try to run those scripts using Linux/Ubuntu 14 command prompt, it is giving "ImportError: No module named configobj".
But if I try to import the same module using ipython, it is not giving any issue.
Python version: 2.7.6 (when I checked with sys.version in ipython)
I have already installed anaconda. I don't know whether it can trigger any issues.
Tried:
Python error "ImportError: No module named"
I have tried changing $PYTHONPATH to point to anaconda lib/ directory as it was suggested in some post on stackoverflow only. Also, checked many questions here but unable to find any solution.
Followed some other links as well.
Thanks :)
Your new module needs to be in a path like
C:\Users\**SOMEUSER**\AppData\Local\Continuum\Anaconda2\Lib\site-packages
then you should install the module from cmd with
python setup.py install
(dont forget to cd to the modules directory in cmd..)
as there should be a "setup.py"-file in the modules directory.
You do not need your env-variable to look into Anaconda2\lib, who did you tell this?!
PYTHONPATH is for your python.exe to call python from cmd...