Messed up Python packages installement? (OS X) - python

I think i somehow messed up installing packages for python and the whole environment. Whenever i want to install something i run into problems like:
directory is not owned by the current user and the cache has been disabled
Also PyCharm thinks i still need to install referenced packages (no modules. Which is wrong since i can use them. When i click on 'install referenced packages' i get the mentioned warning from above plus:
OSError: [Errno 1] Operation not permitted
Hopefully one of you can help! :(
Best regards
Matthias
Edit: At some point i also installed a venv for python. Maybe this relates to my problem. I'm rly sorry i am new to it and have no idea what i'm doing.

You have an issue with your permissions, if you run
which python
you will see where your current version of python is installed. If you're on osx, I seriously recommend downloading brew here: https://brew.sh/. Just paste that command into your terminal, then you should install python by running:
brew install python
This will give you some later instructions, but the brew bundled version of python is alot more robust than the one that gets bundled with your system. Another note is that if you're using virtual environments, consider using virtualenvwrapper here. This should make things run alot more smoothly for you :)
Hope that helps.

Related

Module or Incorrect Python Version Problem?

I'm installing a bunch of python modules on my system that are specific to this code I am going to be working with. Specifically, I used pip install pyda to get the pyda module. To make sure I had gotten all the modules, I went through and ran some of the code snippets, and came across the following error:
ModuleNotFoundError: No module named 'pyda.utilities'
I tried using pip install pyda.utilities, but that honestly doesn't make sense, it should have just come with the pyda module. According to this website https://pypi.org/project/pyda/ it seems like it should come with the package. I tried determining if I just installed it in the wrong python version, but I'm having a difficult time forcing it to use the specific python version that I installed the module in (specifically, I tried to create an alias for /usr/bin/python3.7 or something like this as I have seen on other websites, but it just fusses at me that this is simply a directory, incredibly unhelpful because I can't find the corresponding executable, so I'm a bit confused here).
This is a very long question likely with a very simple answer, any thoughts or help on what the issue might be would be appreciated.
Edit: I have determined that it's a package problem, not a python problem. The command 'pip install pyda' is not actually installing everything, oddly enough, which is why it cannot find the pyda.utilities module. Unfortunately, I think this means I will have to install the package manually. I will keep this question posted because of the useful answer on virtual environments, so thanks everyone.
The answer is indeed straightforward. As #Chris indicated in the comments, start using virtual environments.
It's not as complicated as it sounds and there's plenty of tutorials on getting started with virtualenv for Python, like https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/26/python-virtual-env/
The basic steps:
check you're using the version of Python you want in your virtual environment
if you don't, change directories to where it lives
ensure you have pip and it works
check if you have virtualenv and if you don't pip install virtualenv
create a virtual environment virtualenv /your/env/folder/here
activate the virtual environment with /your/env/folder/here/Scripts/activate
After that, just install the packages you need with pip and they will end up in your virtual environment, with no interference from other Python versions or packages.
Check your python version, if it does not work restart your computer and try run setup.py install on the python command line

Error when installing python

I was trying to install python and for some weird and unknown reason, the installation process is stopped and returns this error
An error occurred during the installation of assembly 'Microsoft.VC90.CRT,version="9.0.21022.8",publicKeyToken="1fc8b3b9a1e18e3b",processorArchitecture="amd64",type="win32"'. Please refer to Help and Support for more information.
This is the first time I encountered such error. I tried 'googling' it but there seems to be no way to fix this up. Do you guys have any suggestions? I just want to install python.
I know this is an old post but I recently ran into this exact same issue.
It was caused by my machine having pending Windows updates that needed a restart to be applied.
Once you've reset your machine remove the C:\Python27 folder (this is important).
Rerun the installer and it should work with no issues :-)
Please provide the environment you have installed.
if windows 2008 R2, because of the rights issue, you need to cancel the installation of pip, it is best not to install in C.
msiexec.exe /quiet /i python-2.7.10.amd64.msi ADDLOCAL=DefaultFeature TARGETDIR=D:\python27
I encountered the same problem. The reason is that Python-dependent system updates need to be rebooted before they can be configured correctly
Try Anaconda it has a lot of libraries already packaged in it. And it comes with conda : a package manager.
conda install my-package
And my-package is already installed.

What is best option from pip, pythontools or easy-install

I am looking for the best option to keep my Python upgraded and to install new packages. I know there was previous discussion like this: Why use pip over easy_install? but they often quite old.
The problem is: I have ubuntu 12.04 at home and Windows 7 at work, would like to keep both of them on the same (newest) version level.
In ubuntu I found that repository contains often old version so I use different procedures to install new packages. I also found that pip installs new version, but did not check other options. In windows I try to install from provided .exe files which sometimes is difficult, and to have ipython working I had to install pythontools. Over the internet I see a lot of opinion about the subject, and advocates to different tools.
Is there a way to keep to different computers (ubuntu/windows) upgraded on the same level and what is the best choice.
I am looking for a constructive opinions like: if you use ... then you don't have to add paths manually but you need to clean downloaded files, or this ... will work perfectly on linux but for the reason ... not on windows.
I would like to use it in ubuntu 12.04 and Windows 7
I'm not sure about Windows. I think people like pip because it does dependencies better than easy_install. But I don't know enough about that to say more. Using virtualenv is a great choice in that it keeps your projects versions. You can also to pip freeze > requirements.txt to get a list of packages you installed within virtual env. This file can then be used to download those versions in another virtualenv. virtualenv installs its own local pip
If someone has problem with installation basic packages under windows this http://viziblr.com/news/2012/4/21/step-by-step-installing-pandas-on-windows-7-from-pypi-with-e.html gives good help. It works well in windows, although does it does not resolve the issue.

importError: no module named _winreg python3

Where can I download _winreg for python3 if I can at all. I have my 'windir' on E:\Windows. I do not know if cx_Freeze did not notice that. I am using cx_Freeze to create an msi installer.
As it says in the _winreg documentation, it has been renamed to winreg in Python 3.0. You should run the 2to3 tool if you're converting code that was written for Python 2.x.
I know this is an old question, but this was the first search result when Googling for ModuleNotFoundError: No module named '_winreg', and perhaps may be helpful for someone.
I got the same error when trying to use a virtual environment folder, which has been created using different (already deleted) python binaries. The solution was recreate the virtual environment:
Delete the virtual environment folder
Run python -m venv <name_of_virtual_environment>
I have found an easy solution for this, Even though i found it after a lot of Rnd, the solution implementation is so simple and straight forward. Hope it can help many people with the same problem.
If you dont have the latest version of Python installed on your machine, You need to download it from (https://www.python.org/downloads/) and then click on Add to path option and just finish the installer.
Please open CMD and move to the python latest version directory, then run the pip install package name (e.g) pip install pygame and it will be successful
1. C:\WINDOWS\system32>cd C:\Users\admin\AppData\Local\Programs\Python\Python37-32
2. C:\Users\admin\AppData\Local\Programs\Python\Python37-32>pip install Pygame
It will install the packages now without any issues.
Downloading
Successfully installed Pygame-1.9.4
C:\Users\admin\AppData\Local\Programs\Python\Python37-32>
If you are still facing issues in Pycharm after trying the above solution, please try the following steps too.
Create new virtual Environment from settings menu and select the latest version of python framework as Project Interpreter and give a new folder path.
select the pip package you want to import. Recompile the code and the error will clear.
Hope this helps.
When you encounter an error like module of simpleai not found,
use
pip install simpleai
in the prompt and then execute. It will get installed.

How can I use pywin32 with a virtualenv without having to include the host environment's site-packages folder?

I'm working with PyInstaller under Python 2.6, which is only partially supported due to the mess MS have created with their manifest nonense which now affects Python since it is now MSVC8 compiled.
The problem is that the manifest embedding support relies on the pywin32 extensions in order to build which is a pain because without including the host's site-packages folder when I create the virtualenv (kinda defeats the point in a build environment) I cannot find a way to install the required extensions so they are accessible to PyInstaller.
Has anyone found a solution to this issue?
I found http://old.nabble.com/Windows:-virtualenv-and-pywin32--td27658201.html (now a dead link) which offered the following solution:
Browse http://sourceforge.net/projects/pywin32/files/ for the URL of the exe you want
Activate your virtualenv
Run easy_install http://PATH.TO/EXE/DOWNLOAD
This works with modern versions of setuptools (circa February 2014, reported by tovmeod in the comments).
If you are using an old version of setuptools (or distribute it merged back into setuptools), you may get this error message:
error: c:\users\blah\appdata\local\temp\easy_install-ibkzv7\pywin32-214.win32-py2.6.exe is not a valid distutils Windows .exe
In which case:
Download the exe yourself
Activate your virtualenv
Run easy_install DOWNLOADED_FILE.exe
I rather hopefully tried "pip install" rather than "easy_install", but this didn't work, and likely never will (citation needed).
Finally, I found but haven't tested a solution at http://www.mail-archive.com/python-list#python.org/msg272040.html which is:
Solved this by copying the pywin32.pth file into my virtualenv site-packages
and editing the file to point to the path.
If the other options don't work for you, maybe this will?
For Python 2.7 or 3.x use pypiwin32.
pip install pypiwin32
OK, well since I had to find a way forward I improvised. I've internally created a git repository with a hacked-together version of pywin32 that will install within a virtualenv using the standard setup.py script. It took a lot of fiddling to make it work right but I managed to get it to load and the dependent code now works as I need it to. If people feel this would be of benefit to the community please post a comment: if I get enough I'll try and put something up on my github account.
This may have been improved since previous answer, since I've successfully installed pywin32 on sandbox on several machines without any specific "hacks" :
$ virtualenv sandbox
$ sandbox\scripts\activate
(sandbox) $ git clone https://github.com/Travis-Sun/pywin32.git
(sandbox) $ cd pywin32
(sandbox) $ python setup.py install
Tested with following environment :
windows 7
git
python 2.7.10 with virtualenv
VS2008. It may also work (but I've not tested yet) with
http://www.microsoft.com/en-us/download/details.aspx?id=44266
Edit: Scratch this for now, appears to be some problems with the installation still...
I got rather tired of the whole situation, and just created a set of converted wheels ("wheel convert <.exe>"). I'll try and keep them maintained for the most recent build, but do shout if there are any issues.
https://tr00st.co.uk/python/wheel/pywin32/
Installation can be done easily using pip and pointing to the package matching your version and architecture. For example, for Python 3.5/amd64:
pip install https://tr00st.co.uk/python/wheel/pywin32/pywin32-219-cp35-none-win_amd64.whl
Caveat: The --upgrade process currently fails, as the uninstall procedure is unable to clean up after itself (Access Denied when cleaning up win32api.pyd) - this is only when removing the temporary directory, which can be manually deleted. Easiest way around this is to uninstall and reinstall instead of upgrading, then manually delete the temporary folder.

Categories

Resources