I am unable to import packages into my python files - python

I am pretty new with python and I have been running into an issue where I pip install a package, but then pycharm says that the package is not installed.
So far I have been able to get around this by just having pycharm install it for me. Now when I am trying to install requests-html, the install works fine, however, whenever I try to import requests_html, I get an error telling me that the package cannot be found. I did some digging through my files and found that it was installed under site packages under a folder called Python311 however, it was not installed under the site-packages folder in venv. I have no idea if this has anything to do with the issue but thought it might.
Now when I am trying to install requests-html, the install works fine, however, whenever I try to import requests_html, I get an error telling me that the package cannot be found. I did some digging through my files and found that it was installed under site packages under a folder called Python311 however, it was not installed under the site-packages folder in venv. I have no idea if this has anything to do with the issue but thought it might. The error message that Pycham displays 'No module named 'requests_html':3'. I have tried reinstalling the package to no luck.

Related

Installed selenium with pip, folder is in site-packages, using correct interpreter, but still cannot import (Win10, Python 3.10.9)

I'm trying to use selenium, but can't get python to recognize it.
I installed it first using "pip install selenium" and "pip install webdriver-manager". It is in the folder "C:\Users\{username}\AppData\Local\Programs\Python\Python310\Lib\site-packages\selenium", but I get the error "ModuleNotFoundError: No module named 'selenium'" when I try to import it.(https://i.stack.imgur.com/dVplU.png)
(https://i.stack.imgur.com/wiREJ.png)
Here it is shown as installed with the command "pip list"
(https://i.stack.imgur.com/QhOu7.png)
I also tried uninstalling it and reinstalling with flags that I saw some people say worked, but it didn't make a difference.
(https://i.stack.imgur.com/VTTMU.png)
I only have one python interpreter version installed, 3.10 (so only one python folder, "Python310"). I have pandas in the same site-packages folder which I can import and use no problem.
If anyone knows what the issue might be, please let me know. I can't figure it out for the life of me.
Okay, I solved the issue by completely uninstalling the interpreter which I got from the Microsoft Store and reinstalling it from the official Python website. Now "from selenium import webdriver" works.
Somehow selenium installed in the global scope is not getting recognized within the Virtual Environment of VS Code / PyCharm.
Solution
You need to install Selenium within the Virtual Environment.
Within the Terminal execute the command:
pip install -U selenium

How to fix module installation problems with the python path

I was trying to install the python chess module and kept getting the same error: ModuleNotFoundError: No module named 'chess'
I looked at some other code and noticed the same problem of not importing the module even though it worked before (in this case it was from sklearn.model_selection import train_test_split).
I figured the problem was that I put all my code in a new folder. Once I took out all of my code from this folder it was able to work, but the chess module still didn't. This made me think that it must be an issue with the path.
Since I use quite a few folders in order to organize my work. How do I fix this?
I don't want to take out all of my code from every folder I have.
I am using VSCode, and I have already installed the chess module, several times, using pip, pip3, python -m install pip, conda, in the command prompt, terminal in VSCode, and miniconda.
So it is not an installation problem.
You can install module manually,
pip install python-chess
Run this command in virtual environment, this will install python chess module

Why are my Python packages being installed to this strange folder?

I am encountering issues with installing certain Python modules on Windows, using pip. In particular, I am using Flask, but I am encountering the error 'flask' is not recognized as an internal or external command,
operable program or batch file. in command line.
However, I am able to run my code properly with python -m flask run for some reason. After investigating, I figured there was a problem with my installation of Flask, so I did pip install --upgrade --force-reinstall flask to hopefully fix the issue. I then encounter the warning message: the script flask.exe is installed in 'C:\Users\Name\Appdata\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH.
Why would my package be installed to this location? My understanding is the default location for a package installation should be C:\Users\Name\AppData\Local\Programs\Python\Python38\Lib instead. How can I fix this. It seems all my packages are being installed to this strange folder, which is giving me countless issues. I have tried force upgrading pip, and reinstalling python to no avail.

ModuleNotFoundError: No module named 'win32crypt'

I'm trying to run a Python module for a school project and I am getting this error ModuleNotFoundError: No module named 'win32crypt' at line import win32crypt.
I've search the website for solution and encountered a post that states pywin32 is required. So I installed it with pip. I also tried installing pypiwin32. None of these installs worked. Now I've tried Dependency Walker to see if there are any dependencies missing and I see at least 100 DLLs that are. How can I fix the issue?
win32cryrpt is a part of the Windows Extensions for Python or pywin32. It is a wrapper around the Windows crypto API. It doesn't make sense to try and install it without pywin32 and if your install of that has failed then that is the problem you have to solve.
Please try pip install pypiwin32 again, being sure to execute it in the correct folder, which is the Scripts subfolder of the Python environment you want to install it in. You may have more than one Python installation without realizing it, and if you run pip from outside that folder, you may get a different instance of pip. The standard location for Python installations is C:\Program Files\Python3x. If the pip install doesn't complete as expected then edit your question to include the messages from the failed install. Did not work isn't enough to go on.

Installing Anaconda and the modules not working

I have just installed Anaconda and then when I tried to use Idle to use the module statsmodels it tells me it doesn't exist:
ModuleNotFoundError: No module named 'statsmodels'
If I then try installing the module using pip it tells me its there.
I have also tried uninstalling Anaconda and installing the modules separately but the connection times out. error image
I am at work so could this be due to the pip module being unable to get through the proxy?
If that is the case why did Anaconda not seem to work either?
I am still unable to get the libraries working on Idle. But I have started using Spyder, which came with Anaconda and all the libraries are working there.
This is fine for my purposes. Though it would be good to know why?
Thanks
Have you tired installing the individual packages via pip? I am running into the same problem. It was working for some, not for others....

Categories

Resources