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

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.

Related

I am unable to import packages into my python files

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.

Trying to use "pip install pandas" and receive the error: ModuleNotFoundError: No module named 'Cython'

I'm very new to Python and have installed Python 3.8, PyCharm community edition and am trying to install pandas. The pandas module shows in in my available packages in PyCharm but when I try to install I receive the above error message.
If I try and run it from the CMD I receive the error: 'pip' is not recognized as an internal or external command, operable program or batch file. And if I try the same command in the Python shell I get an 'invalid syntax' error. I would uninstall everything and start fresh but the fact it's telling me there's "no module named Cython" is making me think something specific is wrong.
Anyone have a solution to this please?
If you are using Python for data science, I think you can make use of Anaconda package manager. It will install the most used libraries for you and provides a user interface for quickly installing and managing the others.
first check is pip installed on your system or not by typing following command:
By default pip file structure will be like
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip --version
if it's not installed then download download pip
Now navigate to following path and install pandas:
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install pandas
Note: Make sure the path is right,while using above paths. according to your system configuration for pip above path might be different.

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.

Setuptools error when trying to install a package

I’m completely new to Python and I want to install the package py-webrtcvad in Windows 7, but I'm stuck at the error ImportError: No module named 'pip.utils.setuptools_build'. There is an answer to this problem in stackoverflow which seems to solve the problem for others, but it doesn't work for me.
Here’s a summary of what I’ve done and tried so far:
Installed Python 3.5 and set up the Windows path environment so
that it works from any directory.
Installed pip for Python.
Tried to install the package with python -m pip install webrtcvad,
but it failed, returning the error Unable to find vcvarsall.bat.
I found a blog that deals with the vcvarsall.bat
problem: blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat. Following the directions of that blog:
First I just installed Visual C++ Build Tools 2015 and tried installing the package straight away (without updating setuptools), but I received a lot of error messages (which I didn’t write down).
I tried reinstalling setuptools, which I did following the directions in https://pypi.python.org/pypi/setuptools: I removed the version of setuptools that came with my Python installation (v20), and installed the latest version (v30). This time I got a different error message when trying to install py-webrtcvad: ImportError: No module named 'pip.utils.setuptools_build'.
Asked for assistance in the Python official chat. They made three
suggestions:
Updating pip with python -m pip install --upgrade pip. Didn’t
work. Again, the error ImportError: No module named 'pip.utils.setuptools_build'.
Reinstalling Visual C++ Build Tools 2015. No difference, same error
again.
Reinstalling Python itself. The Python installer offers three
choices: Repair, modify and uninstall.
Repair: Didn’t work. Same error.
Modify: Doesn’t look like it offers useful modifications for this.
Uninstall: Uninstalled and reinstalled. Still the same error.
I’m out of ideas. Can you help me?
Note: I imagine this should be doable in Windows 7 with Python 3.5. However, if it isn't I'm open to trying anything different. For example, installing a different version of Python would be no problem at all. I could also try installing Linux if that will solve the problem.
There was a bug in version 2.0.8 of webrtcvad that caused it to use the wrong flags when compiling for Windows: it was using -DWEBRTC_POSIX instead of -DWIN32. This might have been the source of the "lot of error messages" you got during one of your early attempts.
The fixed version has been pushed to pypi as version 2.0.9. I've confirmed that pip install webrtcvad works correctly on Windows 10. I'm using a pretty fresh install of Python, so I would try it first without reinstalling setuptools.

easy_install does not configure SimpleITK properly

I'm trying to get some python code running on an EC2 server based on Amazon Linux. The code works fine on my local machine running ubuntu.
One of the dependencies is the SimpleITK module. I install it with
easy_install -U SimpleITK
And it installs successfully, I can import the module in the REPL. However, none of its functions are accessible, I get
AttributeError: 'module' object has no attribute 'ReadImage'
and similar errors for all functions I need. After some investigation, it seems easy_install has somehow messed up the setup. On my local machine, when I do help(SimpleITK) I get the full list of functions, and crucially, the FILE is listed as :
/usr/local/lib/python2.7/.../SimpleITK/SimpleITK.py
But on the EC2 server, it is listed as
/usr/local/lib/python2.7/.../SimpleITK
I believe this is reason for the problems I am getting - on the server, python doesn't know that the 'file' it's talking about is actually a directory, and the actual source for the module is inside that directory.
I've tried reinstalling the module, upgrading setuptools, but the error remains. I tried installing with pip, but pip can't even find the module.
I had the same issue and it was a problem of having several pythons; in my case anaconda and the one that comes with ubuntu. To solve it, I deleted the simpleitk package in each of them (pip uninstall simpleitk) using the pip of each python distribution. Then I installed it again using pip install with the anaconda executable.

Categories

Resources