Python module not found after installing anaconda - python

Hope everyone is doing fine :)
I'm new to python, so I'm having trouble cause I've installed anaconda (for machine learning) and now, my local projects in VS Code with python, don't find modules installed from pip install.
I've searched online and I guess it has something to do with the path... Here's the path when I install the module:
user_stuff.../opt/anaconda3/lib/python3.9/site-packages
I want to install modules into my project on desktop, here's the path:
user_stuff.../Desktop/python-project
I keep getting this error when trying to import:
ModuleNotFoundError: No module named 'qrcode'
How do I change this? It's really frustrating :(

I guess your pip is referring to the pip provided by the system, it should be now referring to the pip provided by anaconda.
$ which pip
$ alias pip="/Users/my-username/anaconda3/bin/pip"
$ pip install qrcode

Do you use jupyter notebook in vs code? I prefer it because there you can easily select the environment you are using. And if you want to pip install anything in a environment you have to first activate it in the console with conda activate env name

Related

I installed package, but python said No moudel <name-packages> any packages I try to install it

I try using pip and pip3 and python -m pip and all ways to install. The terminal says the packages already installed after the first try to install, but when I try to import the package I had error no moudel name.
I feel the peoblem coming form here
But I am not sure
And when I go to packages in pycharm I saw the packages not installed
I appreciate your help
I'm assuming you're using windows.
It looks like you install the package directly in your system and PyCharm are using a virtual environment to run your code.
Try to activate this virtual environment before run your code:
source venv\Scripts\activate
If you see "(venv)" at the begging of your terminal prompt the virtual environment are activated.
Run pip list to check what packages are installed in there and probably you have to install your package another time, this time in your activated virtual environment. The official documentation will help to understand how and why use virtual environments.
After that you can try to run your code directly from the terminal:
python your_file.py
Install the packages from PyCharm itself, not the terminal as I think pycharm is running a virtual environment.
Maybe you can follow https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#packages-tool-window

ModuleNotFoundError: No module named 'zeep'

I have created a virtual environment on which I ran the following command to install Zeep (I am on macOS Big Sur):
pip3 install zeep
To verify if I have correctly installed it I ran:
pip3 freeze
And I can see in the list :
zeep==4.0.0
However, when I run my script using flask run I get the following error:
I have flask installed and activated my virtualenv:
What I don't understand is that when I go directly on python from the command line it does import zeep :
Any help would be appreciated. Thank you.
Two things come to my mind with this problem.
Make sure the venv is activated
source /venv/bin/activate
Make sure flask is installed after activating the venv.
pip install Flask
You are running in an Anaconda/Conda virtual environment, this can be seen from your command prompt. Conda is a package management platform like, but separate to, Pip.
When you install a package with Pip it is not available in an Anaconda virtual environment.
Also you need to take note of where you are actually installing packages to when you run pip. If you run pip outside of a virtual environment then it is going to install packages into your system Python which is not a good thing.
I have flask installed and activated my virtualenv:
How are you activating the virtual environment? Your third screenshot shows the Anaconda installation of Python.

PIP install package - installed but python is not importing

Running on Windows 10, I have Python 3.7.3 installed to my c/users/myUser/appdata/local/programs folder.
When I use PIP to install a package, it seems to run fine, but when I use "import package" in python it doesn't recognize that package. What would cause this?
Running 'python --version' works and also running 'pip --version' works.
PIP shows up in my c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip folder.
UPDATE:
So I was looking through files to determine where the libraries are located that do work with my python. The folder is located in Python/Python37-32/Lib. All of those currently work when importing. However when I do anything with PIP it does not add anything to that folder.
I noticed there are a couple different PIP executables within Python/Python37-32/Scripts which include pip.exe, pip3.exe, and pip3.7.exe. I tried using "pip3.7 install numpy" which also did not work.
I noticed when trying to add an existing package its pointing to the Python37-32/lib/site-packages folder.
SOLUTION:
I removed python from my machine, and reinstalled it. I had the same problem. What I done to fix this was to use
PS
python -m pip install --user package
Also I appended my PATH environment variable with
cmd
setx path "%path%;C:\Users\MyUser\AppData\Roaming\Python\Python38\Scripts"
That seemed to have taken care of my issue. Now when I install a package with PIP I can reference it through python.

install taichi package on python

I tried to run a script with python, it has taichi package downloaded from GitHub.
I have little knowledge of how python packages are installed, now I got error in command prompt like
"ModuleNotFoundError: No module named 'taichi'"
I just installed package downloaded from GitHub: https://pypi.org/project/taichi/#files
Hope someone can teach what should I do to run my script contains taichi package~
To install packages in python you just run the command pip install (name of package) in the command prompt so in your case that would be pip install taichi
How to install virtualenv:
Install pip first
sudo apt-get install python3-pip
Then install virtualenv using pip3
sudo pip3 install virtualenv
Now create a virtual environment
virtualenv venv
Active your virtual environment:
source venv/bin/activate
Now install your package for python
pip3 install taichi
I have figured it our that this Taichi package needs 64 bits python, it also needs LLMV file downloaded. Besides, there should be virtual studio installed in the local computer.
Then this Taichi package can be installed just by using "pip install taichi" in command.
Thanks for everyone's help!
I alse encountered this problem,I confirmed that I have already successfully installed taichi whereas it still showed "no module named taichi" .And here is my solution:tryimport sysandsys.path to check whether the file of the packages is contained in python's search range.
For example,after I inputsys.path in python ,it shows ['e:\\', 'd:\\anaconda2022\\python39.zip', 'd:\\anaconda2022\\DLLs', 'd:\\anaconda2022\\lib', 'd:\\anaconda2022', '', 'd:\\anaconda2022\\lib\\site-packages', 'd:\\anaconda2022\\lib\\site-packages\\win32', 'd:\\anaconda2022\\lib\\site-packages\\win32\\lib', 'd:\\anaconda2022\\lib\\site-packages\\Pythonwin']
I am using anaconda as the python interpreter in vscode ,so the packages of taichi is installed in d:\\anaconda2022\\lib\\site-packages,and I can import it successfully . But previously my sys.path are incorrectly setted to E:\\Python but not D:\\anaconda2022. Python cannot find the packages of taichi from the wrong sys.path.
Check the sys.path in python may help.If it is the one which cause the problem , there are many ways to edit sys.path .I solved it by uninstalling the python for I installed python and anaconda at the same time (- -).

Have MySQLdb installed, works outside of virtualenv but inside it doesn't exist. How to resolve?

I'm using the most recent versions of all software (Django, Python, virtualenv, MySQLdb) and I can't get this to work. When I run "import MySQLdb" in the python prompt from outside of the virtualenv, it works, inside it says "ImportError: No module named MySQLdb".
I'm trying to learn Python and Linux web development. I know that it's easiest to use SQLLite, but I want to learn how to develop larger-scale applications comparable to what I can do in .NET. I've read every blog post on Google and every post here on StackOverflow and they all suggest that I run "sudo pip install mysql-python" but it just says "Requirement already satisfied: mysql-python in /usr/lib/pymodules/python2.7"
Any help would be appreciated! I'm stuck over here and don't want to throw in the towel and just go back to doing this on Microsoft technologies because I can't even get a basic dev environment up and running.
If you have created the virtualenv with the --no-site-packages switch (the default), then system-wide installed additions such as MySQLdb are not included in the virtual environment packages.
You need to install MySQLdb with the pip command installed with the virtualenv. Either activate the virtualenv with the bin/activate script, or use bin/pip from within the virtualenv to install the MySQLdb library locally as well.
Alternatively, create a new virtualenv with system site-packages included by using the --system-site-package switch.
source $ENV_PATH/bin/activate
pip uninstall MySQL-python
pip install MySQL-python
this worked for me.
I went through same problem, but using pip from virtualenv didn't solve the problem as I got this error
error: could not delete '/Library/Python/2.7/site-packages/_mysql.so': Permission denied
Earlier I had installed the package by sudo pip install mysql-python
To solve, copy files /Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7.egg-info and /Library/Python/2.7/site-packages/_mysql* to ~/v/lib/python-2.7/site-packages and include /usr/local/mysql/lib in DYLD_LIBRARY_PATH env variable.
For the second step I am doing export DYLD_LIBRARY_PATH=/usr/local/mysql/lib in ~/.profile

Categories