Which python... file directory PIP - python

I am sure on my Mac 0SX 10.9 I have more than one version of Python 2.7.5.
When I type in
which python
in the terminal, I get /Library/Frameworks/Python.framework/Versions/2.7/bin/python
When I am doing a pip.install it seems those are loading in a different path, they are all under /Library/Python/2.7/site-packages.
When I am in IDLE or my IDE (Sypder) and type
import sys
print sys.path
I get lots and lots of paths that start with /Library/Python/2.7/site-packages.
My problem is when I do a help() or import() on one of the modules I can see in /Library/Python/2.7/site-packages, I get a NameError: name 'Module' is not defined. Examples that I can see loaded in .../site.packages are pandas, nympy, and PyMySQL. But all give me "name of module not found".

Ideal python distribution control on a Mac: use a (free) scientific python environment like Enthought or Anaconda, and use either the real virtualenv package or the provided virtualenv package to control 'virtual environments' in which you can install packages. Virtualenvs really help keep the python distribution clean.
Good Luck.

Python development on a Mac can be a pain in the butt. That's why I set up a Arch Linux through Virtual Box and I'm quite happy with it. However, iOS development with Python using Kivy requires XCode (as far as I know) to deploy the apps on the iOS devices. So I'm in the same boot as you are.
Long story short: Running brew doctor (as in homebrew) in the terminal helped me a lot cleaning up my Python installations on the Mac.

Related

Problems with importing netcdf4 and xarray when debugging - in eclipse + pydev on windows

I have been a staunch user of Eclipse on Windows - mostly for developing Python code. Lately, I needed to do something with the packages xarray and netcdf4. I first used an old version of Eclipse, but when I encountered problems I installed the latest LiClipse - version 8.2.0 (64 bits) on my Windows 10 machine. I use Miniconda 3 py37_4.9.2 (64 bits) with Anaconda Navigator 2.1.2 to manage my Python environments. I wrote a script of only a few lines. When I tried to import package netcdf4, I got an import error immediately that one of the netcdf4 DLLs could not be found after pressing the debug button. When I tried working without direct involvement of netcdf4 but only with xarray, I also got an import error that my packages were not configured correctly. When I started the script - outside Eclipse - from the command-line, there was no problem at all. BTW, I tried running with different Python versions: 3.6, 3.8 and 3.9 but that made no difference. I suspect that Pydev does not work together well with the packages netcdf4 and xarray. Has anybody else experienced similar problems?
It seems like some environment variable isn't properly set when running from PyDev...
Do you have the flag to load conda environment variables set in the interpreter configuration?
i.e.:
Note: if it runs in the command line you can compare the values you have in os.environ from one to the other to find what may be different (in general just making sure that the conda environment variables are loaded should do the trick, but if it doesn't comparing those and setting what's needed in the Environment tab may help).

0x80070643 error while installing Python 3.6

I'm actually using Python for an audio steganography project but I have some troubles.
I searched this error code on the forum, but I found things about SQL installations and not Python.
I'm trying to re-install Python 3.6.5 after an uninstall, because of a bug with pip.
I installed Python 2.7, Python 3.6.5, Python with VS 2017, before uninstall it because it wasn't working.
However, when I'm runing the installer as an administrator, hit "customize installation", tick everything excpet "balblalblabal (this requires VS 2015 or later)", and click on "install", it tells me that :
.
I realy need Python to work and I'm now stuck ...
If anybody here could help me, it would be nice !
Thanks all,
maleik.
PS : I have the log for you :*
The log link
I found this in the log file which you have attached. Try cleaning the registry with CC cleaner and give it a try. If it still doesn't work, try installing python with web installer Python Web Installed 3.6.5.
[3DA0:2968][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to install MSI package.
[3DA0:2968][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to execute MSI package.
[2610:03A4][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to configure per-machine MSI package.
[2610:03A4][2018-12-05T20:46:18]i319: Applied execute package: core_AllUsers, result: 0x80070643, restart: None
[2610:03A4][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to execute MSI package
I installed python from Microsoft store after facing this problem and it magically got installed without any error as it may have directly been installed. I don't know but try if it eorks for you too.
You need to run the installation as a local administrator.
I had the same problem installing Python version 3.9 for the first time on my Windows 10, as this same problem happens to many users trying to install Python, the best solution I accidentally, just like #MANAN AGGARWAL discovered trying to check if I already had a version of Python installed on my computer by the DOS Command Prompt, was:
Open the DOS Command Prompt (cmd) and dictate "python": if a screen shows you a version, it's clearly not the first time you've installed Python, so if you want to upgrade you should try: https: / /www.delftstack.com/en/howto/python/how-to-update-python/ But if you've never installed any version of Python, the solution lies in updating your operating system to the latest version through Windows Update, and open the command prompt and type Python, or go directly to the Microsoft Store and search for Python followed by its latest version. It works without error.
** If by chance it does not automatically install on your PC after downloading, click "install on my devices" and select your computer name.
Why can't I install Python directly from the website file? Please note that when trying to install any software/applications from outside Microsoft's trusted locations, there are high chances of user settings interfering with the installation. When coming, for example, from the Microsoft Store, a chance of success is much greater, even without having problems related to User Permission Settings.
Another important thing to point out here is that installing a lot of software from outside Microsoft's trusted platforms can cause you to change some user permissions which can have positive effects with some software and negative effects with others, even with security your own system if you don't know what you're doing.
it's simple , Try Lower Version Like 'Python 3.6' but Download web install.
install it , then install last python version.
your python will update.
I've faced same/similar problem with installing Python 3.9.12 in a clean Windows 8.1 64-bit (VirtualBoxed test environment).
I thought the issue could have been fixed in a newer version of Python, but the freshest 3.10.10 fails with same issue.
The original log isn't available any longer, but luckily it is quoted in another answer, and the following line reveals the real problem:
Applied execute package: core_AllUsers, result: 0x80070643, restart: None
My log looks the same, and if you scroll the log up, you'll discover that core_AllUsers is a UCRT MSI-installer, which is downloaded from Python site (for 3.10.10 64-bit the link may look like https://www.python.org/ftp/python/3.10.10/amd64/ucrt.msi).
If you download it manually (Python installer is smart enough to do a cleanup even if it fails, so you won't find this MSI in a local cache) and run, it will probably crash. And if it is your case, I have a simple solution - just install update KB2999226 (Update for Universal C Runtime) for your OS, which you can download from Microsoft.
I also faced the similar issue. What the trick worked for me is I installed it for the individual user (as earlier installation was for the all users).
So earlier if one has installed it for the all users then install it for the specific user and vice versa.
I know this is not the resolution of the error faced. However, this approach will install Python which is the main motive to achieve.
I encountered the same issue after installing a fresh Windows 8.1 on my PC.
I solved that by using the Python v3.9 web installation file which you can find here.
However, you can choose any other version that has a web installation file
Note: You need internet connection to use this method.

How to install Tkinter on linux with preinstalled python but without root privilege?

Since on most linux distributions tkinter comes in a different package I have difficulties installing it on my university computer, where we don't have root access.
I get the following error:
/usr/bin/python3: Error while finding spec for 'tkinter.__main__' (<class 'ImportError'>:
No module named '_tkinter', please install the python3-tk package);
I have found this answer:
https://stackoverflow.com/a/10015546/2898702
Then I compiled and deployed TCL and TK in /home/<user>/.local
However the last step python setup.py build seems to expect, that the python interpreter is also installed in a user directory, which is not the case for me.
Is there a way to install TCL and TK without also installing the python interpreter locally? Preferably using pip or easy_install.
In case it is relevant, the distribution seems to be linux mint.
Uname -a gives me: Linux pc404 4.4.0-59-generic #80~14.04.1-Ubuntu SMP Fri Jan 6 18:02:23 UTC 2017 i686 i686 i686 GNU/Linux
For day to day working with Python, even in unrestricted environments, the way to go is to use "virtualenv", which creates a new Python environment in a user controlled folder, and you are then able to install any Python packages you want, regardless of what is available for the system. Since you have a working compiler environment, that works for almost everything.
However, tkinter itself is not available for pip install, since it is expected to come along core Python stdlib (it is about time Linux distributions would stop the idea of leaving it out - it is not like the 5MB maximum it uses would make a difference, when compared to the harm it does by not being there by default. Even customizing the Python package and creating the new one is likely more effort than it saves from anyone).
Anyway, you might try building Python in your local directory - if the system has a compiler, it probably would just work: download the tar.gz source from python.org, uncompress it and just do "./configure --prefix=/home/user/python36" . Now even when that works, it is nice to use virtualenvs for your projects.
Otherwise, you should try to find a pre-compiled Python for the specific Linux distribution, or, see in the instuctions for your package manager, if you can install Python and other packages in a different system root directory, under your control.
Anther alternative, if you have another Linux you have control, build it to a USB stick, and at the University lab, just use the ln command to link it to whatever was the target directory where you built it - that would work as a portable stick.

wxPython for Framework distribution rather than Conda

I've been struggling with getting wxPython work - I'm running a Mac, OSX 10.11.6 El Captain, so the pip install runs into /src/osx/cocoa/mediactrl.mm:52:10: fatal error: 'QTKit/QTKit.h' file not found with the new XCode, and some changes there, and won't compile. So I found an installer, that at least gets it done.
But then wx runs (I only tried to import it in fact) in my conda python 2.7.12.
My goal is to be able to play around with TensorKart and since my default python is conda, when attempting to run the repo, it tells me the usual:
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
I found how George Reilly explains here what to do, but I cannot find the wxredirect.pth and don't know what to do with the bash script. I only have wx.pth within the conda site-packages.
So is it somehow possible to get the wxPython for my Framework 2.7.10 with the .dmg installer? After 6 hours of struggle it seems like the easiest way.
I tried:
copy conda site-packages having to do with wxPython into site-packages within a virtualenv created form the Framework Python as it was in the original G. Reilly's post which no longer works.
create alias in .bash_profile that python is the Framework version but it didn't help.
Thanks a lot!

ImportError: No module named 'resource'

I am using python 3.5 and I am doing Algorithms specialization courses on Coursera. Professor teaching this course posted a program which can help us to know the time and memory associated with running a program. It has import resource command at the top. I tried to run this program along with the programs I have written in python and every time I received ImportError: No module named 'resource'
I used the same code in ubuntu and have no errors at all.
I followed suggestions in stackoverflow answers and I have tried adding PYTHONPATH PYTHONHOME and edited the PATH environment variable.
I have no idea of what else I can do here.
Is there any file that I can download and install it in the Lib or site-packages folder of my python installation ?
resource is a Unix specific package as seen in https://docs.python.org/2/library/resource.html which is why it worked for you in Ubuntu, but raised an error when trying to use it in Windows.
I ran into similar error in window 10. Here is what solved it for me.
Downgrade to the Apache Spark 2.3.2 prebuild version
Install (or downgrade) jdk to version 1.8.0
My installed jdk was 1.9.0, which doesn't seem to be compatiable with spark 2.3.2 or 2.4.0
make sure that when you run java -version in cmd (command prompt), it show java version 8. If you are seeing version 9, you will need to change your system ENV PATH to ensure it points to java version 8.
Check this link to get help on changing the PATH if you have multiple java version installed.
Hope this helps someone, I was stuck on this issue for almost a week before finally finding a solution.

Categories

Resources