This question already has answers here:
PyCharm error: 'No Module' when trying to import own module (python script)
(17 answers)
Closed 1 year ago.
I am using PyCharm and am having trouble importing modules
I set up a venv and imported the dependencies via pip install -r
When I try to run the application and get 'module not found' for all imports.
If I open a terminal in PyCharm and do pip list all the required modules are listed
Further PyCharm can file the modules - I can perform completion when typing the name of the module.
What else can I try?
Sounds like you have more than one python environment on your machine.
So, in my opinion, you need to manage the environments in python IDE.
The same happened to me so this helped me in that.
Do check: https://docs.python.org/3/tutorial/venv.html
You can also seek help from the below article:
https://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/
I solved this by checking the boxes 'Add content toots to PYTONPATH' and #Add source roots to PYTHONPATH'
Related
This question already has answers here:
pip how to remove incorrectly installed package with a leading dash: "-pkgname"
(4 answers)
Closed 1 year ago.
For the past few pip package/module installs I have been performing in Windows 10 Command prompt, I am seeing warnings during the installation stating:
WARNING: Ignoring invalid distribution -jango (c:\users\myusername\appdata\roaming\python\python37\site-packages)
Background system info:
Python version 3.7
Pip version 21.1.1
What is the issue here, and how can I fix this? I looked into some other posts that faced similar issues, but was not able to find any good answers on how to solve it.
Not sure how you would have gotten the django folder, only you can answer that! I'm assuming you mean "django" here not "jango" as "jango" isn't a package.
However if you delete the folder
c:\users\myusername\appdata\roaming\python\python37\site-packages\django (or jango, either one)
then this error will go away when using pip. You can then reinstall it again with pip if you decide that you need it. Obviously make sure nothing is in that folder that you've changed before you do this.
Another thing you could try is renaming the "jango" folder to "django" if it is indeed listed as "jango", perhaps the first letter was removed from the folder name by accident and this is now confusing pip.
This question already has answers here:
Pylint "unresolved import" error in Visual Studio Code
(40 answers)
PyLint "Unable to import" error - how to set PYTHONPATH?
(33 answers)
Imports failing in VScode for pylint when importing pygame
(3 answers)
Closed 1 year ago.
I’ve downloaded pygame but VS code says, in the problems section , it is “Unable to import ’pygame’ pylint(import-error)”
In the terminal it says “ModuleNotFoundError: No module named ‘pygame’”
What could be causing it to not import?
Edit: I added some more specifics
I'm pretty new to python, but I'll try to give you a solution.
You could create a virtual environment in your terminal. If you don't know how to do that, here's a link to a website I found for macos, https://sourabhbajaj.com/mac-setup/Python/virtualenv.html. For windows, https://mothergeo-py.readthedocs.io/en/latest/development/how-to/venv-win.html. Activate the virtualenv, and then pip install pygame inside the virtualenv, so when you run your code, pygame should work as long as the virtualenv you downloaded pygame in is activated.
I really hope this helps as this is my first time answering a question on stackoverflow!
This question already has answers here:
'pip' is not recognized as an internal or external command
(40 answers)
Closed 2 years ago.
I am a new python user. I downloaded python and VS code and ran a few scripts such as print statements and for loops, and everything seems to be working alright.
However, I want to be able to use packages such as numpy. The way that I understand it, I am supposed to go to my computer's command line and type something in such as "pip install numpy," to get numpy installed. However, I have tried typing in many variations of this phrase into my command line, such as "pip3 install numpy", "python install numpy", and things of this nature. No matter what I type in, I get the message "_____ is not recognized as an internal or external command, operable program or batch file."
I am having trouble even getting my command line to recognize that I have python set up and downloaded... and yet, I can clearly access python in VS code as well as on my computer in general. One possible problem is maybe I am in the wrong directory? But I do not know how to find this out of change to the correct directory. Can someone please tell me what to type in or what I am doing wrong? I am on a windows 64 bit computer.
Thank you so much! :)
There is two step for installing python in windows. If you want to user python in your command line, you have to set a PATH. These can help you:
1- https://geek-university.com/python/add-python-to-the-windows-path/
2- How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
After set PATh, you can use python in your command line. Then you should install pip tool. This link gives you a hand to do that:
1- https://phoenixnap.com/kb/install-pip-windows
After installing python and pip, i recommend you to google about virtualenv. It's a wide used tool for python programming.
Normally you dont need to install numpy. Just use in your code:
import numpy as np
Run the script. If you dont see any errors it is because you already had it.
This question already has answers here:
Python Interpreter Mode - What are some ways to explore Python's modules and its usage
(3 answers)
Closed 8 years ago.
OS Windows XP SP3
situation
I installed three python exes on my machine.
Python 2.6
Python 2.7
Python EPD ENABLED (for pylab)
problem
I installed wxPython and in the selection I decided to install it to Python in system registry
I don't know to which python this package was installed.
what I tried
I tried writing import wx on all the shells and found that it was installed to EPD python.
bigger issue
I don't want to keep doin this each time I install a package. So is there a command that can be used in the shell or any other way, so that I can know about all the packages installed?
please help me with this issue.
Type help() in the shell. And then in the help prompt type modules to see a complete list of all modules.
You can get a complete list with sys.builtin_module_names and pkgutil.walk_packages():
import pkgutil
import sys
print sys.builtin_module_names + [name for module_loader, name, ispkg in pkgutil.walk_packages()]
The modules subcommand of help() puts a friendlier interface on top of these results.
This question already has answers here:
python3 --version shows "NameError: name 'python3' is not defined"
(2 answers)
Closed 6 years ago.
I use Windows 7 and Python IDLE.
I'm trying to use easy_install but gut this error:
Traceback (most recent call last): File "", line 1, in
easy_install NameError: name 'easy_install' is not defined
In included in my 'Path' the directory where it has been installed (C:\Python27\Scripts).
Any thoughts on what could be wrong?
Maybe...
In Python IDLE > File > Path browser, I cannot see C:\Python27\Scripts. How to add it ?
Make sure you've done all of this.
Adding Python to Windows Path.
Downloading and installing setuptools for appropriate python version.
Adding Scripts directory (for instance C:\Python27\Scripts) to Windows Path.
You can check installing by opening a command prompt and typing "easy_install"
easy_install is an executable program, not a Python script. Run it from the Windows command line, not from Python.
I once had a similar problem when I was trying to use easy_install. I finally was able to install both easy_install and pip although I really needed just one of them to get the job done.
If you are still struggling with this problem, I would suggest you follow these instructions I put together recently for others who asked me to. It is fairly easy to follow in order to re-install easy_install on your machine. I also explain how to add the directory to your path - which sounds like you have done already but still seeing the above problem. Here is the link that might help you solve this problem.
Simple easy_install installation guide for windows
I hope this helps you get back up and running again! Good luck!