Mac M1 python packages error after upgrade to python3 - python

I am writing a project in NativeScript and I received the following error the last few days when I tried the commands: ns run ios or ns doctor.
Couldn't retrieve installed python packages.
The Python 'six' package not found.
I tried python and pip upgrade and also the command pip install six.
Nothing of them fixed the problem.
I believe that is not a NativeScript issue, is about the configuration of the python packages in my machine. I mention that I am using a MacBook with M1 chip and it is running the 12.5 OS version.
I will appreciate any suggestions on this situation.

Lastly, I found the solution. It was about the python folder into the path /usr/local/bin/python
You could check it by the following command: where python
In my case this folder is missing, perhaps I deleted it after the upgrade of the python3.
That was a mistake both folders should exist on this path!
If you type: where python you should receive: /usr/local/bin/python
If you type: where python3 you should receive: /usr/local/bin/python3
In order to fix the error, I installed python again by using the brew install pyenv
this suggestion helps me to install it properly.
In the end, in order to eliminate all errors I installed the Python six package by using the command:
pip install --ignore-installed six

Try doing it with the python virtual environment. Following are the steps.
Create a virtual environment.
Activate the virtual environment.
Run the pip install command with the virtual environment active.
Implement as follows:
use correct version of Python when creating VENV
python3 -m venv venv
activate on Unix or MacOS
source venv/bin/activate
activate on Windows (cmd.exe)
venv\Scripts\activate.bat
activate on Windows (PowerShell)
'venv\Scripts\Activate.ps1'
install the required package in the virtual environment
python3 -m pip install --upgrade pip
python3 -m pip install six
Note: This works only when you are in the virtual environment.

Related

Error in installing venv for python3 on mac

While installing a virtual environment by running the following command on terminal:
python3 -m pip install --user venv
I'm encountering the following error:
ERROR: Could not find a version that satisfies the requirement venv
ERROR: No matching distribution found for venv
Please help me with this! I believe since default python is version 2.x in macOS I must try installing virtualenv but I require venv.
You cannot install venv with pip: venv is a module from the standard library since Python 3.3. So you don't need to install it, just start using:
python3 -m venv path/to/new-venv
Venv doesn't exists. I guess that you might want the package virtualenv.
Venv is commonly used as the name of virtual environment created by virtualenv.
So, the command is:
python3 -m pip install --user virtualenv
python3 -m virtualenv venv

Command "python3 -m pip install [...]" failed with error code 1 in None

I am trying to install the PyInstaller module for python through the terminal on my mac, and it is not working.
I am trying to install this module so I can package a program. I have tried to install through terminal through different commands (e.g. "pip install pyinstaller), but it is not working, even though I know I have PIP correctly installed.
When trying to install, I type, python3 -m pip install pyinstaller.
The result is Command "/usr/local/bin/python3 -m pip install --ignore-installed --no-user --prefix /private/var/folders/w5/rlzrygt57j3c3nl4p29d2djc0000gw/T/pip-build-env-mjrd7sir https://files.pythonhosted.org/packages/b2/86/095d2f7829badc207c893dd4ac767e871f6cd547145df797ea26baea4e2e/setuptools-41.2.0-py2.py3-none-any.whl#sha256=4380abcf2a4ffd1a5ba22d687c6d690dce83b2b51c70e9c6d09f7e8c7e8040dc https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl#sha256=f4da1763d3becf2e2cd92a14a7c920f0f00eca30fdde9ea992c836685b9faf28" failed with error code 1 in None
I have upgraded PIP, and tried using sudo python3 -m pip install pyinstaller, but I am not in the sudoers file.
Please help
Create a virtual environment for your project in your project directory.
python3 -m venv env
source env/bin/activate
Test which python is activated
which python
This will show that your local python in the virtualenv you just created is now the current python
Try installing now using
pip install pyinstaller
This ought to work for you. Always use virtual environments for your projects instead of installing system wide libraries unless you really need to set this up for the system.

Install Python 3.6.3 in Virtualenv using pip in WIndows 10?

How do you install Python 3.6.x in a virtualenv using pip in Windows 10?
pip install python, pip install python3, pip install python3.6 don't work.
Pip and virtualenv are two separate tools. Pip is a package manager, you will use it to install packages into your virtual environment once it has been set up. Pip does not actually manage the virtual environment. Virtualenv is the tool that handles creating virtual environments.
First, you should check if you have virtualenv installed with virtualenv --version. If you do not have it, you will get an error that virtualenv is not found. You can use pip to install virtualenv with pip install virtualenv.
Once you have virtualenv, you can create a python 3.6 environment with virtualenv -p python3.6 /path/to/myvirtualenv. You will need an installation of python 3.6 for this command to work, so download and install python 3.6 first if you do not have it.
I believe that on windows if you don't have python 3.6 in your PATH variable, you may need to point directly to the python 3.6 installation instead with virtualenv -p /path/to/mypython3.6 /path/to/myvirtualenv.
See Virtualenv User Guide

Python 3.5 install pyvenv

I am trying to get a virtual environment for a repo that requires python 3.5. I am using Debian, and from what I can tell, python 3.5 does not have an aptitude package. After reading some posts, it was recommended to download 3.5 source code and compile it.
After running the make and install, python3.5 was installed to /usr/local/bin. I added that to the $PATH variable.
Here is where I ran into problems. After I ran:
$ cd project-dir
$ pyvenv env
$ source env/bin/activate
$ pip install -r requirements.txt
I was getting issues with needing sudo to install the proper packages. I ran:
$ which pip
and it turns out that pip was still using the /usr/local/bin version of pip.
$ echo $PATH
returned
/home/me/project-dir/env/bin:/usr/local/bin:/usr/bin:/bin: ...
I am assuming that because the /usr/local path came after the virtual environment's path in my PATH variable, it is using that version of pip instead of my virtual environments.
What would be the best way to run the correct version of pip within the virtualenv? The two options I can think of is moving the binaries over to /usr/bin or modifying the activate script in my virtual env to place the virtualenv path after /usr/local.
Option 1
You can upgrade pip in a virtual environment manually by executing
pip install -U pip
Option 2
Good method to upgrade pip inside that package
python -m ensurepip --upgrade does indeed upgrade the pip version in the system (if it is lower than the version in ensurepip).
You are facing this problem, because venv uses ensurepip to add pip into new environments:
Unless the --without-pip option is given, ensurepip will be invoked to
bootstrap pip into the virtual environment.
Ensurepip package won't download from the internet or grab files from anywhere else, because all required components are already included into the package. Doing so would add security flaws and is thus unsupported.
Ensurepip is not designed to give you the newest pip, but just "a" pip. To get the newest one use the manual way at the beginning of this post.
To check ensurepip version you can type into python console import ensurepip print(ensurepip.version())
More Findings for further reading:
To upgrade ensurepip manually using files - https://github.com/python/cpython/commit/f649e9c44631c07e707842c42747b651b986dcc4
What's the proper way to install pip, virtualenv, and distribute for Python?
Comprehensive beginner's virtualenv tutorial?
Kesh's answer led me in the right direction.
The problem was that I didn't actually have pip installed in my venv.
It turns out, when I built python3.5 from source, I did not have the libssl-dev package. It looks like one of the dependencies of ensurepip was the python ssl package that didn't get installed because I didn't have libssl-dev.
To fix the problem, I rebuilt python 3.5 for source with the libssl-dev package installed. The rebuilt python now included the ssl package, which allowed ensurepip to install pip in my virtual environment.
Try installing it locally:
pip install --user -r requirements.txt
which would, I believe, install the file in a sub-directory of your $HOME directory (which your virtual env I would think would set). Otherwise I think you could just use:
/path/to/virtualenv/pip install -r requirements.txt

Installing python packages with multiple versions on OSX

I am attempting to install a package for python3.4 on Mac OSX 10.9.4. As you know, python ships with OSX, so when I installed python3.4 I was happy to find that it came with its own version of pip, that would install packages to it (installing pip on a mac with multiple versions of python will cause it to install on the system's python2.7.)
I had previously tried installing this package (https://pypi.python.org/pypi/chrome/0.0.1) with my first installation of pip (the one tied to python2.7) and found that it successfully installed on that version, but not on any others.
I ran an install with the new pip keyword for python3.4 (which when called by itself spits out the help page so i know it works) and it told me that the package was already installed and to try updating. The update revealed that I already had the most recent version. so I tried uninstalling it from just the python3.4 and reinstalling to no avail, and got the same results when uninstalling pip from python2.7 and reinstalling only on version 3.4.
I know that's a bit hard to follow but hopefully that makes sense.
I also reviewed the content here with no success.
RESOLVED:
while python did have a directory named the same as a directory it uses with packages, this was not the correct directory, for me it was in a subdirectory of library. while documentation said that referencing pip2 would cause the package to install on python3.4, this was false. however, referencing pip3.4 worked for me.
My suggestion is that you start using virtualenv.
Assuming you have 3.4 installed, then you should also have pyvenv. As for pip and 3.4, it should already be installed.
Using for example version 3.4 create your own virtual environment and activate it:
$ mkdir ~/venv
$ pyvenv-3.4 ~/venv/py34
$ source ~/venv/py34/bin/activate
$ deactive # does what is says...
$ source ~/venv/py34/bin/activate
$ pip install ... # whatever package you need
With version 2.7 first install virtualenv and then create your own virtual environment and activate it. Make sure that setuptools and pip are updated:
$ virtualenv-2.7 ~/venv/venv27
$ . ~/venv/venv27/bin/activate
$ pip install -U setuptools
$ pip install -U pip
$ pip install ... # whatever package you need

Categories