Import _constant_time from cryptography.hazmat.binding - cryptography

When importing _constant_time
I was getting attribution error: _init.cffi_1_0_external_module
I decided to go check in _constant_time.
And what is discover is _constant_time is not a python module but rather a cpp compiled library. (.so) .
So how is python importing from .so file? Or is something missing in cryptographic package?

According to an answer on Russian StackOverflow, you need to install cffi module as well.
sudo easy_install -U cffi
or
sudo pip install -U cffi
And on Windows the syntax is more like:
python -m pip install -U cffi
(according to How to run Pip commands from CMD?)
-m is needed on Windows since Windows doesn't interpret "shebang" (#!) interpreter lines so pip can't be run directly as on Linux/BSD/Unix/whatever, but needs to be run from python. -U tells pip or easy_install to install latest version of cffi available.
English version of linked Russian page

Related

Python3.10 source venv has changed

I went to do some python leetcode on a personal repo and after I upgraded my Kubuntu to 22.04 I realized the current venv wasn't working.
I had figured I would need to recreate the venv.
Installed python3.10-venv but I cant source and activate it.
In fact venv/bin/activate doesn't exist anymore.
The folder only contains three files
python python3 python3.10
I had tried but no dice
source venv/bin/python3.10
So naturally source venv/bin/activate doesn't work. Ideas?
I've installed Ubuntu 22.0.4 and I've had the same problem as yours and I solved that problem in this way.
install venv:
sudo apt-get update
sudo apt-get install python3-virtualenv
Create venv:
virtualenv --python=/usr/bin/python3.10 (VENV-NAME)
python3.10 -m venv (VENV-NAME)
source (VENV-NAME)/bin/activate
check & update pip:
pip list
and update pip for example(in my pc):
(/home/amin/Desktop/prog/Django/moein/coffeinrider.com/Project/A/(VENV-NAME)/bin/python3.10 -m pip install --upgrade pip)
When trying to create a virtual env using venv for Python, a version of Python that is already installed system-wide must be used, but a version of the venv library from the system must also be used. These are two pre-requisites for setting up a virtual environment.
WARNING: I did this in a hurry because I needed it but please be warned: this may break your system Python with a result that applications that rely on it may break.
The problem I had, matching symptoms given here, seems to be that when trying to create a venv using Python 3.10.8, the venv module for Python 3.8.10 was being used.
So, given Python 3.8 and Python 3.10 are already installed using apt, first of all I uninstalled these packages:
sudo apt purge python3-venv python3.8-venv
sudo apt autoremove
Then I linked python3 to point to Python 3.10:
cd /usr/bin
sudo rm python3
sudo ln python3.10 python3
Then I installed the venv for Python3.10:
sudo apt install python3.10-venv
This now means creating a virtual environment for Python 3.8 doesn't work (because Python3.8 venv has just been removed). I'm not sure if there is a means to have them both working, and I haven't yet tried to just install python3.8-venv again and try them both, as I need my 3.10 environment working quickly, right now ;-). But it seems possible there has been some conflict introduced when following the usual upgrade route within Ubuntu 20.
However, venv for Python 3.10 should now work as expected:
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ python -V
Python 3.10.8
(.venv) $ pip install --upgrade pip
...
(.venv) $ pip list
Package Version
---------- -------
pip 22.3
setuptools 63.2.0
It has been updated to source venv/local/bin/activate

No module named tensorflow even after installing with pip

I'm trying to follow this guide to test this new algorithm: https://github.com/lalonderodney/SegCaps
I can't do it in my PC, so i'm using another server with Putty. Now I'm connected with the other server.
First of all I installed TensorFlow as indicates in the guide with :
pip install -r requirements.txt
After I wrote this code: ./main.py segcaps.png
in which segcaps.png is the image that i want to use
Finally I wrote python main.py --data_root_dir data
that is the only required parameter with the directory containing imgs and masks folders.
Now it gives me an error:
ModuleNotFoundError: No module named 'tensorflow.python.framework'
I searched it in the directory tensorflow/python/framework and it exists.
So, i don't know how to solve it. Ideas?
If you have multiple Python versions installed, then you'll (most likely) have multiple pip versions installed too. Make sure that the pip command you use installs the package(s) into the Python version you want it to. It may so happen that the package got installed into python2 but you wanted it in python3.
Since using pip did not install the packages in python3, pip3 is most likely to the PyPI for python3. Try
pip3 install -r requirements.txt
and that should work.
In case you have an EnvironmentError you can try this (bad idea):
pip3 install -r requirements.txt --user
This solves the problem most of the times on standalone machines. I'm not sure about the server; insufficient permissions might block this.
Why is the --user flag a bad idea? Read: What is the purpose “pip install --user …”?
You can use pip show tensorflow to see if it is installed or not.
As for ModuleNotFoundError try uninstalling keras and reinstalling an earlier version by pip install keras==2.1.6

No module named install

Yes you read it right!
I am trying to install pygame, so I downloaded the whl file and copied it to my project's folder, in the command prompt I navigated to the folder and entered
python -m install --user pygame-1.9.2-cp35-cp35m-win32.whl
Now if you can help me here that would be really appreciated, why is the error so rare that I couldn't find it anywhere.
Python doesn't have a module called "install". The module you're looking for is probably pip.
Just type in the command prompt:
python -m pip install --user pygame-1.9.2-cp35-cp35m-win32.whl
And pygame should start being installed.

Downloading PostgreSQL Mac Download Error

could you please advise me of a solution you may know for downloading PostgreSQL. I am trying to install 9.6.5 version, but also tried the 10.0, same error.
I am using an installation option for Mac operating system OS Sierra from website: https://www.openscg.com/bigsql/postgresql/installers.jsp/
I am getting an error:
Have tried to run the instruction sudo easy_install pip in the command line and it installs the pip file successfully. However I am still unable to install the PostgreSQL.
Please could you advise what the issue may be?
I have also installed Homebrew (it did not help).
I do already have anaconda and Python installed, as well as latest versions of R and RStudio.
I have now found a solution to the above problem (on Mac). Execute the following command in your terminal:
sudo easy_install-2.6 pip
If that does not work execute:
sudo easy_install-2.7 pip
This allows the PostgreSQL to be downloaded correctly.
I followed the instructions suggesting using easy_install-2.7 but still got an error very similar to that from the OP. I had to specifically install pip 9.0.0 with
sudo easy_install-2.7 pip=9.0.0
after which the PostgreSQL install worked.
The default pip is now v10, so it's probably a string compare issue in the installer.
Here is the solution that worked for me on Mac High Sierra 10.13.4:
Clear out the brew cache $ rm -rf ~/Library/Caches/Homebrew
Clear out the site-packages $ sudo rm -rf /usr/local/lib/python2.7/site-packages
Reinstall Python $ brew reinstall python This pulls down python-3.5.6.high_sierra and put it in /usr/local/bin/python3
But which python still shows /usr/bin/python
The solution is to run $ brew install python#2 which pulls down python#2-2.7.14_3.high_sierra
Now which python shows the correct path /usr/local/bin/python which is also where all your pip stuff is installed, so now pip will work.
Ensure the latest version of pip is installed with $ sudo pip install --upgrade pip

PIP install pandas not working

I am trying to install pandas with .whl file in a work computer but I get " cannot fetch URL" error. I have up to date version of PIP installed.How can I get this to work.I'm using Python 3.5.Any help will be appreciated.
I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-package.whl and use
pip install some-package.whl
python -m pip install some-package.whl also works if pip is not found in PATH
Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. If pip is not installed, this page can help:
How do I install pip on Windows?
Note: for clarification
If you copy the *.whl file to your local drive (ex. C:\some-dir\some-file.whl) use the following command line parameters --
pip install C:/some-dir/some-file.whl
I guess since you are on a work computer
try this
sudo pip --proxy=http://username:password#proxyURL:portNumber install yolk
for example:
sudo pip --proxy=http://202.194.64.89:8000 install elasticsearch
202.194.64.89:8000 is my PROXY,